How would I disable player movement within the server without changing WalkSpeed?

In my game, players can use powers, but I would like to make it so that they have to stand still when using certain ones. I simply cannot change their WalkSpeed as the client is already doing that (I understand it’s a bit unsafe but there’s a lot an exploiter can do when it comes to client stuff, plus I need the quickest response times so I do this stuff on the client). The server <> client replication is not friendly when it comes to client changing stuff such as WalkSpeed and JumpPower. I already tried playing around with Player.DevComputerMovementMode but this doesn’t fully work when the player is already moving prior to this.

What’s the best approach to this?
Also, I would not be able to look at any replies until tomorrow morning.

1 Like

Post by GollyGreg
How to stop player movement! - #2 by GollyGreg

Can this be achieved by the server?

No, CAS is local

but you can fire an RE to the client and order them to freeze/unfreeze

2 Likes

Oh I see, telling the client to go on and off, perfect thanks!

1 Like

Oh also, one more question sorry to bother, does this also work for mobile devices as well as joystick controllers?

I expect it to, but I’m not 100% sure

Just pointing out this isn’t ideal. Since this is done client-side, an exploiter can just enable his controls again with a single line of code. Also, players with slower internet connections will experience a delay.

2 Likes

tbh exploiters can do a lot with their own character that will replicate for some reason

like setting their characters walkspeed to 100…

You should have measures on the server to prevent this

1 Like

true, but it’s much easier for them to set it than for us to patch it

1 Like

If I understand correctly, you want to stop the player for some time, I’d just have anchor the HumanoidRootPart of the player, then he will not be able to move, and the animations will work as they should.

4 Likes

All movement is replicated from the client to the server so to fully disable character movement (as recommended above) anchor the HumanoidRootPart and then for added security you could hold a table of all the “frozen” characters. Constantly check(Preferably using heartbeat) to make sure they haven’t moved. If their position has changed simply set their position back to the spot they were frozen at. When you want them unfrozen simply Unanchor their rootpart and remove them from the table of “frozen characters”. This can be done serverside and it will be secure so those pesky exploiters can’t mess around with the system. If you don’t mind much about the security aspect then just do the anchoring stuff and ignore the table mumbo-jumbo.

4 Likes

From my experience this can only easily be done using local scripts. My method is to require the roblox player module and disable / enable movement.

-- Local Script --
local PlayerModule = require(LocalPlr.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()

-- Player cant move  --
Controls:Disable()

-- Player can move --
Controls:Enable()

With this you wont have to worry about changing walk speed or any other values.

Now what I recommend regarding worries about exploitability:
Create a Remote Event and on the server you can keep track of position for the duration of them not being allowed to move. And right before allowing them to move again check if their position is within ~5 studs of the original position and if not teleport them back to their original position.

3 Likes

How is this not ideal? Anything and everything involving player controls and movement is client-authoritative. The only thing the server can possibly do is nullify a player’s physics and use body forces at the expense of performance, or anchor a player’s root which is not desirable in OP’s scenario.

Indeed, it is not desirable but talking with the other devs it appears to be the safest and least complicated.