Basically, I am making a script to stop a player from jumping if there 'stamina' is under 15. When I test it in-game, it shows no errors, but doesn't work, so here is the script.
--The script is under the screengui. local sa=script.Parent.S--A int. value under the screengui. local fill=script.Parent.Main.Fill--A frame to go over the main part to show visually where your stamina sits. local hum=script.Parent.Parent.Parent.Character:FindFirstChild("Humanoid") local txt=script.Parent.Main.TextLabel coroutine.resume(coroutine.create(function() while true do wait(3) if sa.Value < 100 then sa.Value=sa.Value + 10 elseif sa.Value > 100 then sa.Value=100 end end end)) coroutine.resume(coroutine.create(function() while wait() do fill.Size=UDim2.new(sa.Value *0.01, 0, 1, 0) txt.Text="Stamina:"..sa.Value.."/100" end end)) hum.Changed:connect(function() if sa.Value >= 15 then sa.Value = sa.Value -15 else --Implying speed is a factor in this hum.Jump=false end end)
Thanks in advance. :)
The problem is that you're trying to run two while loops at the same time.
--The script is under the screengui. local sa=script.Parent.S--A int. value under the screengui. local fill=script.Parent.Main.Fill--A frame to go over the main part to show visually where your stamina sits. local hum=script.Parent.Parent.Parent.Character:FindFirstChild("Humanoid") coroutine.resume(coroutine.create(function() while true do wait(3) if sa.Value < 100 then sa.Value=sa.Value + 10 elseif sa.Value > 100 then sa.Value=100 end end end)) coroutine.resume(coroutine.create(function() while wait() do fill.Size=UDim2.new(sa.Value *0.01, 0, 1, 0) end end)) hum.Changed:connect(function() if sa.Value >= 15 then sa.Value = sa.Value -15 else --Implying speed is a factor in this hum.Jump=false end end)
-- You can make your player stop jumping by doing this while true do wait(0.1) game.Workspace.YourNameUwantHere.Humanoid.Jump = false end