In short i have a part with a number value named "Time" and has its number set to 100 and a surface gui with a text label inside of the surface gui. There is a script inside the text label that is supposed to tell the text label to set its label as the number value minus 1 every second to make it count down from 100. There is a button beside the part that adds 10 points to the number value on click. The maximum is set as 100 and if the player tries to spam the button, it will be capped at 100 and wont go any higher. My problem is when i try to set a minimum number value at 0 (so the numbers will stay at 0 and wont go any lower) it wont work. It looks fairly confusing to begin with as I've not done something like this before (or have really ever used values in a script). It's supposed to be a fuel bar and the button refills it just for context. Here's the script starting from the button to the main countdown script.
script.Parent.ClickDetector.MouseClick:Connect(function()
if game.Workspace.CountdownPart.Time.Value <= 100 then
game.Workspace.CountdownPart.Time.Value = game.Workspace.CountdownPart.Time.Value + 10
end
end)
And here's the countdown script.
local countdown = script.Parent.Parent.Parent.Time
script.Parent.Text = countdown.Value
for i = 1,countdown.Value do
wait(3)
countdown.Value = countdown.Value - 10
script.Parent.Text = countdown.Value
end
while true do
if countdown.Value >= 100 then
countdown.Value = 100
end
if countdown.Value <= 0 then
countdown.Value = 0
end
end

4 comments
Ah okay this is a fresh perspective! had no idea this thing existed. Ill test it out soon and tell you if it works correctly.
Tried it and it posted this error: Expected ')' (to close '(' at line 15), got 'end'. It seems like your going into the right direction though. Can you correct this soon? I'm not too sure whats causing it.
I was able to remove the error by removing the third end) and adding the ")" to the second end. Apparently this caused the script to repeat the problem and now the numbers still lower into the negatives but the numbers dont go past 100 as usual.
Hold on a second, why do you have a fuel and refill system in your question title, but then talk about a timer in the details? What is your whole system trying to do?