Best way to disable movement from player?

I’m making a weapon, and during the attack animation I’m trying to disable movement, and I’ve tried a few ways to disable movement, like:

Background:
The weapon is an axe, and the rest of the script works, after you click,

  1. it checks limitations (like debounce or stamina),
  2. it checks if the player is in the air, and if they are falling or rising using the players Y velocity
  3. If the player is grounded: play the grounded attack
  4. If the player is falling: play the falling attack
  5. If the player is rising, start falling and play falling attack

Options to freeze player:

  1. anchoring the HumanoidRootPart
    Issues:
    -Freezes player in place no matter where, even if slightly below ground
    -Keeps current animation playing, if they were runnng they keep running

  2. controls:Disable()
    Issues:
    -Player has to release and press W again after the animation to move forward again, instead of just holding W the whole time

  3. Turning jump and walk power to 0
    Issue:
    -Can still jump for some reason idk why
    walk power part works tho, I just feel like there is a better way tho idk

These are the best options i could find, but is there a more efficient way to stop movement or am i just doing something wrong

1 Like

JumpPower works if you set UseJumpPower to true:


local hum = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")

hum.UseJumpPower = true
hum.JumpPower = 0

You can just make a function that stops the movement of the character and use it like this:

local hum = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
hum.UseJumpPower = true

local stopmovement = function()
	hum.JumpPower = 0
	hum.WalkSpeed = 0
	print("Movement paused")	
end

wait(5)
stopmovement()

2 Likes