How do I handle player speed?

I want to know how I should be handling player speed with crouching, sprinting, and anything that affects walk speed. If I let the server handle all the speed changes, crouching would feel delayed because I need to send a signal to request a speed change. But if I let the client handle all the speed changes, it would feel janky because every time I want to change the player’s speed on the server, I would need to send a signal to the client. I can’t split client and server handling because that would just create a tangled mess.

handle all speed on the client because hackers can just move however they want anyways

then if you want to prevent speed hack you can check if the horizontal player movement is too much compared to their walkspeed for a given amount of time

Given that humanoids can change their speed on the client side anyway, you can do so as well. What I would do is have client side and server side checks related to player speed mods (crouching, sprinting, etc). The client checks would be there to protect normal players and give them instant responses of what they can and can’t do, the server checks will be there to prevent exploiting. On top of that I would create a system that sends signals to the server(for example I’m sprinting, I’m crouching, etc) and the server stores those signals, which humanoids send them, and at which intervals. Then it can use them to monitor and prevent players from cheating (for example check if the humanoids have permission to send those signals at a given moment given their latency and in-game permissions/cooldowns, or if the humanoid speed and actions on the server side/on replication match the signals they send over).

Basically what I’m trying to convey here is that you let the client do whatever they want with their character speed, but you still send data over to the server and compare it with what is actually going on on the server-side to monitor the situation. Then you create an anti-cheat that uses these indicators to figure out if a player is doing something they aren’t supposed to.

If you want to manage walk speed on both the client and server without the issue of the server overwriting the client’s side, then you will need to employ signalling between the two sides. However, to reduce latency when signalling client->server, just modify the walk speed on the client, and then when the signal reaches the server, overwrite it with the same value.

There is no harm in overwriting it since it’s the same value on either side, but if the signal arrives late, there won’t be a noticeable delay since it’s also being set on the client (initially). Signalling the server is simply to just replicate the change since client walk speed changes don’t replicate automatically, and this also prevents the server from making inaccurate walk speed updates because the walk speed value on the server is kept up-to-date from these client->server signals.