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)
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.