My jump stamina script

so this works fine for the most part but i dont want it to lower the players stamina every time they press the jump button because if theyre ragdolled for example, pressing the jump button would lower stamina even if they arent jumping

script

local bar = script.Parent

local stamina = 100


local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local humanoid = char:WaitForChild("Humanoid")


local isJumping = false

local uis = game:GetService("UserInputService")


humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	if stamina == 0 then return end

	isJumping = true
	
	wait(1)

	if isJumping then
		humanoid.JumpPower = 50
		wait()
	end
end)


while wait() do

	if stamina == 0 and isJumping then
		isJumping = false
		humanoid.JumpPower = 0
		wait(5)
		humanoid.JumpPower = 50
	end


	if isJumping then
		humanoid.JumpPower = 50
		stamina -= 5
		isJumping = false
		wait()
	else
		stamina += 0.75
		wait()
	end


	stamina = math.clamp(stamina, 0, 100)

	bar:TweenSize(UDim2.new((1/100) * stamina, 0, 1 ,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1)
end
1 Like

I’m a bit confused, do you mean like the player is supposed to lose stamina when they jump but they keep losing stamina after they jump?
If that’s the case I think you need a debounce.

1 Like

wait yeah nevermind let me try that

lol make sure that works though cuz i didn’t fully understand

or assuming you gave me solution i assume it worked out :slight_smile:

i had a debounce earlier but i wasnt using it correctly but it works now thank you!

2 Likes