How to Prevent Movement While Playing Animations?

Hello everyone, I’m currently working on an animation module and I want to stop movement and jumping while animations are playing. After much consideration, I’ve decided not to set walkspeed and jumppower to 0 (as this approach has potential risks in the future). Instead, I am using the method Controls:Disable(). However, I’m encountering an issue. If I press the W key and then disable and re-enable controls, the character will not move even though I’m still pressing the W key. I have to release and press the W key again for it to work. This can be quite awkward for players, especially when animations play frequently. Does anyone have a solution to this?

Here is part of the local script:
– Client Script
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local ControlPlayerMovement = ReplicatedStorage:WaitForChild(“ControlPlayerMovement”)
local PlayerModule = require(game:GetService(“Players”).LocalPlayer.PlayerScripts:WaitForChild(“PlayerModule”))
local Controls = PlayerModule:GetControls()

ControlPlayerMovement.OnClientEvent:Connect(function(action)
if action == “disable” then
Controls:Disable()
elseif action == “enable” then
Controls:Enable()
end
end)

1 Like

You can Anchor the HumanoidRootPart when you play the animation

1 Like

Thanks ,anchor is good way, bug i can’t use it. Because i want the character can be hit to fly

change the walkspeed to 0? you can also google it

1 Like

thanks, I think a lot how to deal with my problem . In the end ,i use the walkspeed to 0way ,thanks . (at the begin ,i don’t use it because that i am afraid will come with bug ,but now i fight out how to prevent the bug .)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.