Setting Humanoid properties on client/server? or both

Right now when a player opens a menu, I prevent them from moving, but I’m doing this on the server. Which means I fire a RemoteEvent. Now problem with this is when you clsoe the menu, the player has to wait for the remote to fire the server and set their speed/jump back. So I was thinking, would it be worth while setting their speed/jump on both client and server? Client for quick response times, server for the sake of everybody else in game (preventing a player from moving who shouldn’t be, etc.)

-- just server side
function MovementManager.Set(player, active)
	local Character = player.Character
	if not Character then return end
	
	local Humanoid = Character:FindFirstChild('Humanoid')
	if not Humanoid then return end
	
	Humanoid.JumpPower = active and 35 or 0
	Humanoid.WalkSpeed = active and 18 or 0
end

Movement.OnServerEvent:Connect(MovementManager.Set)

Just use LocalScript for this. These properties replicate to the server when you change them through client.

I highly recommend doing this on the client to avoid the latency. The client has ownership of their humanoid, so setting the JumpPower and WalkSpeed on the client will replicate automatically. I don’t believe doing it on the server has any benefit in terms of security, since the client still has ownership.

Edit: as pointed out below, the numeric value of these properties won’t replicate, but the physics will. (For example, changing the WalkSpeed of a player on the client will make them faster, but the value of the WalkSpeed won’t change on the server.)

@cc @sz_s
Wouldn’t changing the players speed/jump from the client be bipassed by exploiters?

1 Like

It can, but setting it on the server can be easily bypassed as well.
You can test this by setting a player’s WalkSpeed on the server, then doing it on the client.

How can I prevent exploiters from moving then…?

You need to perform some sort of server-side checks on the player’s position. I’m sure you can find lots of resources in other threads about anti-exploit protection.

This is not true. On the server, speed won’t change (if the server were to check Humanoid.WalkSpeed) BUT player’s position will replicate, so yes, it can be changed by the client via localscript.

3 Likes

Anchor HumanoidRootPart of their character from the server. They won’t be able to move at all while it is anchored and this cannot be bypassed (unless you use remotes).

Is there a particular reason why you want to stop them from doing so? As you said in your main post, you did say that this occurs on a menu, so I don’t think an exploiter would get much functionality even if they could move.

I would also just do this on a local script.