Variable not accurately updating

Hello,

I am struggling trying to make a dummy mimic a players movements. The code is already mostly written and i can debug that. The main issue is a variable that is not correctly storing the updated speeds of the player.

–Issue
The variable tracks the players speed but only if it surpasses the previous player speed.
For example if the player started at a initial speed of 16. The player presses a button and the walk speed is changed to 32. The variable accurately tracks that speed. But when the player slows back down to 16. The variable while actively tracking player speed still somehow keeps getting 32. It will only change if the player moves faster.

--Visual of problem




The third screen show the a walk speed of 16 yet, the variable is still printing 32.

–relevant code
Screenshot 2025-05-05 233942
Screenshot 2025-05-05 233823

–ideas
I think the problem may be because it is a local script I am using for the process? I am very new the game development so I don’t even know where to even start for debugging. It works, kind of? I Bolded the sentence that may help solve the problem that I think.

Are you changing the walkspeed in a local script anywhere?

Probably the change in WalkSpeed ​​caused by the button is caused by the UserInputService, and WalkSpeed ​​is only changed on the client side. This can be solved by using a remote event when the WalkSpeed ​​is changed by a button.

Yes, The screenshots of the code are from a local script directly connected to the player.

Thank you, I just set the walk speed to 16 within the local script and it worked smoothly