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