Hello! So I have this script that I modified, and it works great for what I’m looking for. The thing is, it has a slight bug with the stamina bar.
How do I make it so that the stamina (ii) doesn’t go below 0 / the stamina doesn’t go past the left?
VIDEO:
SCRIPT:
while wait() do
print(ii)
if humanoid then
if humanoid.MoveDirection:Dot(humanoid.MoveDirection) == 0 then moving = false else moving = true end
if tired then
TS:Create(player.Character.Humanoid, TweenInfo.new(1.25), {WalkSpeed = NormalWalkSpeed}):Play()
if not moving then
ii = ii + 1
end
if ii > 0 then
tired = false
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .5, true)
end
elseif running == true then
if moving then
TS:Create(player.Character.Humanoid, TweenInfo.new(2), {WalkSpeed = NewWalkSpeed}):Play()
ii = ii - .025
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', 1.5, true)
if ii == 0 then
tired = true
ii = -1
end
if ii == 0 then tired = true end
elseif ii < 10 then
ii = ii + .035
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .5, true)
end
if not moving then
ii = ii + .035
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', 1.5, true)
end
if ii <= 0 then
Bar.BackgroundColor3 = Color3.fromRGB(255, 193, 194)
end
if ii > runRef then
Bar.BackgroundColor3 = Color3.fromRGB(222, 255, 202)
else
Bar.BackgroundColor3 = Color3.fromRGB(255, 193, 194)
end
else TS:Create(player.Character.Humanoid, TweenInfo.new(1.25), {WalkSpeed = NormalWalkSpeed}):Play()
if not moving and ii < 10 then
ii = ii + .035
Bar:TweenSize(UDim2.new(ii / 10, 0, 1, 0), 'Out', 'Quint', .5, true)
end
if ii <= 0 then
Bar.BackgroundColor3 = Color3.fromRGB(255, 193, 194)
end
if ii > runRef then
Bar.BackgroundColor3 = Color3.fromRGB(222, 255, 202)
else
Bar.BackgroundColor3 = Color3.fromRGB(255, 193, 194)
end
end
end
end