To Stop Movement While Certain Animation is Played

I created this script to play an animation the script is working fine, but I want to stop all movements when this animation is played.

Script: https://gyazo.com/5a4a969725f79219fd432f6874d7e97a

Problem: https://i.gyazo.com/5664f6eb4ad4edacbc40e0753e530194.gif

4 Likes

You can set the player’s WalkSpeed to 0.

2 Likes

You can either anchor the HumanoidRootPart of the player’s character or you can set JumpPower and WalkSpeed of the player’s character’s humanoid to 0. I’d suggest the first one the most, then unanchor when the animation is stopped.

9 Likes

You could sink the input of various input types using the ContextActionService. This prevents some input types from being operable and is fairly reliable (aside from the fact that exploiters can unbind the action, which shouldn’t matter unless you absolutely need the player to not move while playing this animation).

1 Like

I don’t know if it would be the “fastest” solution… But you could use in this same script a pause in the player’s movements, because even if you set 0 the speed and jumping force, wouldn’t work, the player would still be able to move if found a speed bug.
Best example:

Mouse.Button1Down:Connect(function()
       local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
       controls:Disable()
       wait(2)
       controls:Enable()
end)
1 Like