Better way to detect when player jumps?

When a player jumps, it sends it as the player jumping loads of times. Is there a more reliable way of checking when the player jumps?

Code:

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local staminaBar = playerGui:WaitForChild("StaminaBar"):FindFirstChild("Bar")
local humanoid = game.Players.LocalPlayer.Character.Humanoid
local debounce = false

humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	if humanoid.Jump == true then
		staminaBar.Size = staminaBar.Size - UDim2.new(0.1, 0, 0, 0)
	end
end)

UserInputService has an event called JumpRequest, which as the name implies, runs when the player makes a request to jump. It should work for what you want seeing as this is a localscript

Hm, still seems to send the request a few times instead of only once

Okay looking through the page, you need a debounce for this as it’ll send a lot of requests for one jump

1 Like

How do you time the debounce perfectly with the jump, then?

And how do you tell if the character holds the spacebar down, and continues jumping?

This isn’t a workable solution, but is marked as one.

1 Like