So, I'm making a really crude run GUI with a stamina system. It increases your speed and everything, but it won't decrease the stamina value. Output didn't give me anything on the script. Can someone please help me?
Here's the script:
local running = false
local Character = script.Parent.Parent.Parent.Parent.Character
local left = 100
function onButtonClicked()
if running == false and left > 0 then
running = true
Character.Humanoid.WalkSpeed = 25
script.Parent.Text = "Walk"
end
end
while running == true and left > 0 do ---This is probably where the issue is located.
left = left - 1
wait(0.5)
end
while running == true and left == 0 do
running = false
script.Parent.Text = "Run"
Character.Humanoid.WalkSpeed = 16
end
while running == true do
running = false
Character.Humanoid.WalkSpeed = 16
script.Parent.Text = "Run"
end
while running == false and left < 100 do
left = left + 1
end
script.Parent.Parent.Bar.Text = ""..left
script.Parent.MouseButton1Click:connect(onButtonClicked)

1 comment
Thanks. Just had to do some minor changes, but it works. Once again, thanks.