Detecting constant jumps

So I’m making a stamina system.

uis.InputBegan:Connect(function(input, gpe)
	if gpe == false then
		if uis.KeyboardEnabled == true then
			if input.KeyCode == Enum.KeyCode.Space then
				onRequestReceived()
				staminaRemote:InvokeServer("jump", false)
			end
		end
	end
end)

This works ok but when a player is holding down the space, it only registers once. StateChanged will not be efficent for just one stamina script, I tried GetPropertyChangedSignal for “Jump” but it fires so many events, like 20-30 per jump. I don’t know what to do now.

How about you just detect if Space is being held

Well, I have to detect player is landed or not because if I add a wait, when they are falling, it will still detect. I guess this isn’t a good method at all.

Try using

Humanoid.Jumping:Connect(function()
    print("Jump")
end)

Edit - Just took a look at the documentation, and ran a bit of a test, and it fires twice, once when the Jumping humanoidstatetype begins and once when it ends. The event passes in a parameter to detect which is which,


Character.Humanoid.Jumping:Connect(function(entering)
	if entering == true then
		print("Jump Began")
	end
end)
1 Like

That’s it, thanks! (30 charss)

1 Like