Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I unbind this function to remove moving capabilities?

Asked by 6 years ago
game.Players.LocalPlayer.leaderstats.Stop.Changed:Connect(function()
    if game.Players.LocalPlayer.leaderstats.Stop == 0 then
        ContextActionService:UnbindAction("Left")
        ContextActionService:UnbindAction("Right")
        ContextActionService:UnbindAction("Jump")
    else
        ContextActionService:BindAction('Left', onLeft, true, 'a', Enum.KeyCode.Left, 
                Enum.KeyCode.DPadLeft)
                ContextActionService:BindAction('Right', onRight, true, 'd', Enum.KeyCode.Right, 
                Enum.KeyCode.DPadRight)
                ContextActionService:BindAction('Jump', onJump, true, 'w', Enum.KeyCode.Space, 
                Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)


    end

end)



Yes, the the code does run (it registers when the variable changes)

Im trying to prevent player movement, but the players still moves.

Why wont the players function unbind?

(yes, this is a snippet of larger code)

1 answer

Log in to vote
1
Answered by
Mayk728 855 Moderation Voter
6 years ago

A much easier way to stop a player from moving at all is Humanoid.WalkSpeed.

Here's how you do it.

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild('Humanoid')

Humanoid.WalkSpeed = 0 --Player cannot walk.
Humanoid.JumpPower = 0 --Player cannot jump.
0
I know i couldve done this, but i did my way to prevent All input and make other stuff easier, but you know what? screw it User#17125 0 — 6y
0
Rip. Mayk728 855 — 6y
Ad

Answer this question