The sales rep field value in the lead record is populated using a workflow. For the combination of scripts and workflows, it will still follow the scripted record order. However, the script is being executed first, followed by workflow.
This was the reason, in the user event scripts, old records, and new records remained the same even though the sales representative was actually changed.
Solution: For resolving the issue, use workflow action scripts or workflow instead of user event scripts.