How to set player jump height

Hello, I am setting player height to 0 to disable jumping, however I eventually want to enable it again, I used

local jump = game.StarterPlayer.CharacterJumpHeight

jump = 7.2
wait(10)
jump = 0

i’ve tried changing it multiple ways and used .value aswell and nothing seems to work, any solutions? (the script is inside serverscriptservice)

5 Likes

Set the humanoids JumpPower to 0 when you don’t want to jump and set it back to default after debounce

1 Like

thanks, I tried this however am still having no luck, did I define humanoid correctly?

function onTouched(hit)
local h = hit.Parent:findFirstChild(“humanoid”)
if h ~= nil then
h.JumpPower = false

end

end

script.Parent.Touched:connect(onTouched)

1 Like

Should be

local h = hit.Parent:FindFirstChild(“Humanoid”)
2 Likes

still not working even after changing it to what you said, is there an easier way to change it, since I will be changing it constantly to make it efficient, like defining characterjumpheight directly and changing the values?

1 Like

JumpPower is number, not a true/false.
Humanoid.UseJumpPower is a true/false as shown in that documentation.

Humanoid jump power shouldn’t be set to 0, it’s best to use Humanoid.SetStateEnabled Humanoid:ChangeState() as per the link.

1 Like

I looked at the thread and it seemed to work fine while using a debounce, however I am still having issues, all I want to do is run a function, then in the middle of the function I want to disable jumping for 10 seconds, then re-enable it, I am not the best scripter, please can you show me the code,
that would be helpful

2 Likes

It may be that local h = hit.Parent.findFirstChild("Humanoid") is your issue.
Try
print(h.Name) after that line to see what is hitting the Part.

If it’s not registering anything you’ve got to see why the function isn’t being called in your script. It may be inside a section of code that isn’t running.

Are you setting UseJumpPower to true?

local debounce = false

script.Parent.Touched:Connect(function(hit)
   local humanoid = hit.Parent:FindFirstChild("Humanoid")
   if humanoid and not debounce then
      debounce = true
      humanoid.UseJumpPower = true
      humanoid.JumpPower = 0
      task.wait(10)
      humanoid.JumpPower = 50
      debounce = false
   end
end)
1 Like