Humanoid Problems

So I’m currently working on a stamina system for a game. I’m making it so that when you jump, it subtracts stamina, and when you reach below a certain point, you can no longer jump.

I’m trying to use the Humanoid.Jumped event, but for some reason it only fires every few jumps. I’ve also tried Humanoid.Changed, but that event fires whenever the jump button is pressed, so if you spam the button, it will drain stamina.

What’s the best method of tracking a humanoid’s jump?

1 Like

Try Humanoid | Roblox Creator Documentation instead.

For the spam issue have you tried a Debounce Patterns | Roblox Creator Documentation?

1 Like

use :GetPropertyChangedSignal()

    if humanoid.Jump then
        --subtract stamina
1 Like

You can try using Humanoid.StateChanged. It is currently the best way to do it.
Here’s an example Code of how you would use it:

-- Variables
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local LocalCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local LocalHumanoid = LocalCharacter:WaitForChild("Humanoid")

-- Main
LocalHumanoid.StateChanged:Connect(function(NewState, OldState)
	if NewState == Enum.HumanoidStateType.Jumping then
		-- Code

I meant to say Humanoid.Jumping, I’ve tried it and sometimes it won’t register. Also, because the jump input can happen at random times, I wouldn’t know what to put for a debounce.

1 Like

Are you referring to “Humanoid.Jump”? That isn’t an event that’s a property which describes if the humanoid is jumping or not (via a Boolean value), instead use the “Humanoid.Jumping” event as previously suggested.

1 Like