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

How to disable jumping through a script?

Asked by 1 year ago

Hello! I need to disable jumping through a script so it can be toggled on and off. How can I accomplish this?

3 answers

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

You can also use the event UserInputService.JumpRequest.

-- disable jumping
Player.Character.Humanoid.JumpPower = 0
-- or
Player.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- or
game:GetService("UserInputService").JumpRequest:Connect(function()
    Player.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end)
Ad
Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

The most straight forward way is to set the player’s JumpPower to 0, or you can disable the humanoid’s jump state.

--to disable
player.Character.Humanoid.JumpPower = 0
--or
player.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

--to enable
player.Character.Humanoid.JumpPower = 50
--or
player.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
0
Thanks! Sxribbly 16 — 1y
Log in to vote
1
Answered by
bbissell 346 Moderation Voter
1 year ago

The easiest way to do this is to set your JumpPower to 0. You can do this from a script:

Player.Character.Humanoid.JumpPower = 0

Answer this question