'Humanoid.Jumping' firing 2 times?

Hi,

I wanted to make so my player have two different jump animations and they will play after each other (Jumped - plays first animation; Jumped again - plays second animation).

I used variable with a animation name to define which one to play

Example of my onJump function:

whichJUMP = "jump"

function onJumping()
   whichJUMP = (whichJUMP == "jump" and "jump2") or (whichJUMP == "jump2" and "jump")
   print(whichJUMP)
   playAnimation(whichJUMP, 0.1, Humanoid)
   jumpAnimTime = jumpAnimDuration
   pose = "Jumping"
end

This is the output:
Screenshot_374

TL;DR When i press SPACE to jump it prints 2 times and so it will never change the whichJUMP variable… Is this a bug or i do something wrong?

I think it may due to how the event works, as even UserInputService.JumpRequest experiences the same issue, you’ll have to put a debounce on the Jumping event to prevent multiple fires

Something like this?

function onJumping()
	if jumpdeb == true then return end
	jumpdeb = true
	whichJUMP = (whichJUMP == "jump" and "jump2") or (whichJUMP == "jump2" and "jump")
	print(whichJUMP)
	playAnimation(whichJUMP, 0.1, Humanoid) --when the animations stops i set debounce to false
	jumpAnimTime = jumpAnimDuration
	pose = "Jumping"
end

I just tried it and it don’t work…

Yes, but you forgot to set it back to false, try this?

function onJumping()
	if jumpdeb == true then return end
	jumpdeb = true
	whichJUMP = (whichJUMP == "jump" and "jump2") or (whichJUMP == "jump2" and "jump")
	print(whichJUMP)
	playAnimation(whichJUMP, 0.1, Humanoid) --when the animations stops i set debounce to false
	jumpAnimTime = jumpAnimDuration
	pose = "Jumping"
	wait(0.5)
	jumpdeb = false
end

No, i set a debouce to false when animation stops. I put a comment so you will understand, but it didn’t worked.

But your variant (set it to false after time and not after animation ends) works!

Thanks for helping :heart:

1 Like

I think it was probably because it still being set to false way too fast, I didn’t read that comment so I was confused a bit so I thought it waiting a bit then setting it to false would work, which I’m glad it did!

If you have anymore issues don’t be afraid to make another post!

1 Like