How do I stop a player from moving? (walking / jumping)

lately i’m working on a power simulator and i made a script that adds power when the player activates the pushup “Tool” and with that i have to temporarily stop his walking / jumping.

I already have a script that executes this, but if the player constantly changes tools the speed and the player’s jump will always be 0.

This is the script I have…

Pushups.Activated:Connect(function()

local Hum = Pushups.Parent.Humanoid

local OldSpeed = Hum.WalkSpeed
local OldJump = Hum.JumpPower

if not debounce then
debounce = true

Hum.WalkSpeed = 0
Hum.JumpPower = 0

local Ani = Hum:LoadAnimation(script.SpeedTraning)

local Power = game.Players[Pushups.Parent.Name].leaderstats.Power
Power.Value = Power.Value + 199


Ani:Play()	
Ani.Stopped:Wait()

Hum.WalkSpeed = OldSpeed
Hum.JumpPower = OldJump

debounce = false
end
end)

I want to know how you guys would make this script. and if it has a function of “Locking” the walk and the jump without the method of setting it to 0.

.

3 Likes

I would combine setting the speed and jump power to 0 and anchoring the HumanoidRootPart.

I think it would affect my animation. and I already have it but when the player changes tools quickly when the animation is playing at speed and the jump locks at “0”.

It doesn’t affect the animation at all. Anchoring the HumanoidRootPart only make it not be able to move or be pushed by other players.

I made a thread asking this and got solved, check it out:

--This is a LocalScript
local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()---GetControls

Controls:Disable() 
6 Likes

I need this in a Script but the Script does not detect PlayerScrips

I think you can check when the player has entered and do everything else in the server.

There are multiple ways of doing this. I like to use ContextActionService for this:

local ContextActionService = game:GetService("ContextActionService")
local FreezeAc= "freezeMovement"

ContextActionService:BindAction(
    FreezeAc,
    function()
        return Enum.ContextActionResult.Sink
    end,
    false,
    unpack(Enum.PlayerActions:GetEnumItems()))

To give back movement just UnbindAction
If you want you can also set JP/WS to 0