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. :)

11 comments
Okay, it allows me to jump now, and it removes stamina, but now it doesn't regen it.
It also does not stop me from jumping once it is depleted.
You mean the bar or the actual value?
The bar, I am not sure about the value, but it won't stop me from jumping anyways, so I assume both.
Try now.
Great, now, the only problem is that when it is low, I can still jump.
I've edited it a small amount, try it again. The if statement might be slowing it down.
Still allowed to jump with under 15 stamina.
I've just tested it with a value, it may be the bar deceiving you maybe? Do you have a text on it that shows the exact amount of stamina?
No, I will add that real quick.
Yea, when it is under 15 it doesn't remove stamina, but you still jump, ill edit the question with how I show the value though.