i have this fully functioning stamina bar but whenever i test my game or play it live, the stamina goes up to 101 even though i never specified it to.
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")
local jumpDebounceTime = 0.5 -- wait 1 second before they can jump again
local nextJump = 0 -- don't change this one, it's the time they can jump again
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if stamina == 0 or nextJump > tick() then
return
end
nextJump = tick() + jumpDebounceTime -- schedule next possible jump
isJumping = true
wait(1)
if isJumping then
humanoid.JumpPower = 50
wait()
end
end)
while wait() do
if stamina == 0 then
isJumping = false
humanoid.JumpPower = 0
wait(5)
humanoid.JumpPower = 50
end
if isJumping then
humanoid.JumpPower = 50
stamina -= 15
isJumping = false
wait()
else
stamina += 1
wait()
end
local staminatext = script.Parent.Parent.Stamina
staminatext.Text = (math.floor(stamina).." / 100")
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