Serverside WalkSpeed changes not replicating

I’m working on a walkspeed module to modify a players walkspeed more effectively. However, while working on it I realized the server wasn’t able to modify the player’s walkspeed. I’ve done some research and here’s what I understand so far.

  • Once a client has set it’s own walkspeed, the server is no longer able to interfere with it until the humanoid is reset

I made a place file to test this. Inside the file, I have 2 scripts, one in serverScriptService, the other is a local script in starterPlayerScripts.

Server code

--//serverScriptService script
wait(8)
local plyr = game.Players.charcle
plyr.Character.Humanoid.WalkSpeed = 5 --second set
wait(5)
print("set on server")
plyr.Character.Humanoid.WalkSpeed = 5 --fourth set, doesn't replicate

Client code

--//starter player script
repeat
	wait()
until game.Players.LocalPlayer.Character

wait(5)
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 50 --first set
wait(5)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 50 --third set

The resulting playtest goes as follows

  • client sets speed to 50
  • server successfully sets speed to 5
  • client sets speed to 50 again
  • server sets speed to 5, but this doesn’t replicate and the player still moves at 50 walkspeed

My question is why is the server successful in replicating the walkspeed on the first try, but not the second? Is there any hope for modifying walkspeed from both the server and the client, or should I give up and modify it exclusively on either client or server?

The answer to your first question is that once the client sets a property, any changes to the property made by the server will not be replicated to the client. For your second question, I suggest modifying the player’s WalkSpeed on the server’s end, since anything on the client’s side can be modified by exploiters.

2 Likes

Adding to what @BuilderDolphin said -

  1. When you’re creating a property or anything on the client, it only would be visible to you, and thus - the server wouldnt be able to edit that and modify it. [because it was only created on the client, meaning only that client would see this, and won’t affect the server].

  2. There are only few exceptions that won’t require remotes when making them on client, your case is sadly not one of them. Changing WalkSpeed requires a remote, otherwise, it’d be easily bypassed and exploitable.

solution

--server
plyr.Character.Humanoid.WalkSpeed -= 0.1 --subtracts from the walk speed 
plyr.Character.Humanoid.WalkSpeed = 5 -- sets the walk speed, replicated
1 Like

The value on the server side has never changed from it’s 5 when changing it on the client.

The server still sees the player as 5 walkspeed, so setting it again won’t replicate.

For anyone wanting to know exactly what’s happening.

Solution simply makes the changes twice, as FartFella did, one to be slightly less, and to set it back to the number you want.
This will ensure you’ll set your value you want again.

4 Likes

Incredible explanation, thank you

Thanks for explaining to him, i was busy working on something else :smile: