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.
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.
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.
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.
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.
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.