Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I unbind this function to remove moving capabilities?

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

✓ Accepted answer

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.

2 comments

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

0

Rip.

This discussion is preserved as it was. New answers, comments, and votes are closed.