What script can cancel the player walking movement? Like, in a way their only option is to jump.
But also in a way I can turn it on and off with a simple function.
Is setting the player walkspeed to 0 a good idea?
Quick edit: added the scripting and help extra tags
Setting the player’s WalkSpeed to 0 is a straightforward way to stop movement, but it might not be the most flexible or efficient method. Instead, you can use the ContextActionService to disable player movement, which allows for more control and can be easily toggled on and off.
Example:
local ContextActionService = game:GetService("ContextActionService")
local ACTION = "freezeMovement"
-- Disable movement
local function disableMovement()
ContextActionService:BindAction(
ACTION,
function() return Enum.ContextActionResult.Sink end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
end
-- Enable movement
local function enableMovement()
ContextActionService:UnbindAction(ACTION)
end
-- Example usage
disableMovement() -- Call this to disable movement
-- enableMovement() -- Call this to enable movement
My bad, I forgot to exclude the jumping, here’s how you can do it:
local ContextActionService = game:GetService("ContextActionService")
local ACTION = "freezeMovement"
local Disable = {
Enum.PlayerActions.CharacterLeft,
Enum.PlayerActions.CharacterRight,
Enum.PlayerActions.CharacterForward,
Enum.PlayerActions.CharacterBackward,
}
-- Disable movement
local function disableMovement()
ContextActionService:BindAction(
ACTION,
function()
return Enum.ContextActionResult.Sink
end,
false,
unpack(Disable)
)
end
-- Enable movement
local function enableMovement()
ContextActionService:UnbindAction(ACTION)
end
-- Example usage
disableMovement() -- Call this to disable movement
-- enableMovement() -- Call this to enable movement
Wow thanks really! I’m new here I did not knew how to do that. My plan was to now make a new topic for the infinite jump, if you helped me there as well I would love it