Humanoid.Jump not working reliably (100% REPRO)

This one was pretty frustrating to figure out.

I made a jump pad. It’s just a part that wants to make the character jump when it’s touched.

I believe the right way to do this is with setting Humanoid.jump = true. I have also tried humanoid:ChangeState(Enum.HumanoidStateType.Jumping).

This doesn’t work. BUT if I set it 10 times in a tight loop, it does work.

I’m not the first user to encounter this. Can we please fix it.

Here is a repro. It fails 100% of the time when run locally.

Bad Jump Pad Uncomment Hacky Code to Fix.rbxl (21.0 KB)

Maybe the humanoid state table is missing some transitions? I shouldn’t have to know the current state of the humanoid to make it jump.

13 Likes

i will take a look into this issue (if possible, drop your repro place file in this thread)

Already did, it’s at the bottom of my post.

3 Likes

This seems to be due in part to the following line in StarterPlayerScripts>PlayerModule>ControlModule:

self.humanoid.Jump = self.activeController:GetIsJumping() or (self.touchJumpController and self.touchJumpController:GetIsJumping())

This is done every render step, effectively overwriting any value you set on the Jump property.

Yuck.

That’s problematic. I think the root issue is that causing a jump as a side-effect of setting Humanoid.Jump is a design flaw. Instead, there should be a function, Humanoid:Jump().

I wonder if it is done the way it is to make it easier to cancel jumping in some games?

6 Likes

I actually disagree. In my obby game i made a year or two ago, I have a jump pad that looks like this:

local deb = false
script.Parent.Touched:connect(function(p)
if deb == false then
	if p.Parent:FindFirstChild("Humanoid") then
		deb = true
		p.Parent.Humanoid.JumpPower = 200
		p.Parent.Humanoid.Jump = true
		print("jumped")
		wait(1)
		p.Parent.Humanoid.JumpPower = 50
	end
end
end)

Surprisingly, jumped only prints once, and your character also jumps really high.
I’m pretty confused as why it doesn’t work in your situation.

After downloading your place file, I can approve that it doesn’t work 100% of the time, but sometimes the character also jumps without uncommenting the for loop.

It could be that the problem has been partly solved, but i’m not 100% sure.

Here’s the jump model for reproduction:
JumpPadRepro.rbxm (3.0 KB)

My specific method is to actually do this on the clientside – Remember, player physics is handled on the client, so making players jump or move in any manner on the clientside is a valid action and is arguably preferred since it ensures zero-latency feedback for given actions.

In my own game I have a double-jump script that simply just sets the humanoid state to jumping (doesn’t set Jump = true, it calls ChangeState instead) and it works 100% of the time without error. That, and it’s super short:

local humanoid = character.Humanoid
local oldJumpPower = humanoid.JumpPower
humanoid.JumpPower = 100
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
humanoid.JumpPower = oldJumpPower

No waits necessary since this is all on the client so latency is not a problem. Works great. You may consider trying to reference the jump pad from the client and connect Touched there.

1 Like

Yeah one of the most frustrating things about debugging this issue was that I had other jump pads I loaded from free models and those all worked with Humanoid.Jump = true.

I spent an hour cutting and pasting code into my code trying to do a binary search through the problem space.

Then it turned out I had a write-write conflict with some hidden core script. :gun:

2 Likes

I did try this. Doesn’t work reliably in my case. It probably sets Humanoid.Jump = true behind the scenes.

Maybe the issue is that I am setting Humanoid.Jump = true from a server-side script.

If setting this server-side is problematic, it would be cool if I got some feedback about that. For instance, this property could be read-only server side.

6 Likes