This is quite an invalid script. You’re trying to perform an arithmetic function (subtraction) on both an instance and an int which won’t really work. And you’re using a while true do loop for countdowns which, there is a better way.

```
local duration = 5 * 60 --multiply minute by 60 to get total seconds of minutes
for i = duration, 0, -1 do
local minutes = math.floor(i/60) -- divide variable i by 60
local seconds = math.floor(i%60); -- divide variable i by 60 and use % to get remainder for seconds
if (minutes < 10) then
if (seconds < 10) then
script.Parent.Text == "0"..minutes..":".."0"..seconds;
else
script.Parent.Text == "0"..minutes..":"..seconds;
end
else
if (seconds < 10) then
script.Parent.Text == minutes..":".."0"..seconds;
else
script.Parent.Text == minutes..":"..seconds
end
end
wait(1);
end
```

After this, you won’t have to worry about checking if the text is 0. The loop automatically stops once it reaches either 0 or -1, and stops yielding the entire script (although it’s recommended to do wrap this in a coroutine).

## EXPLANATION

##
Numeric For Loop (click to expand)

Now, what did I do here? I used a numeric for loop

(Documentation about it can be found here.)

The For loop in Lua has two variants: numeric and generic. The generic one is for usually iterating over dictionaries and arrays, the numeric one is for repeating a task (usually) for a specified amount.

It can be in any form, either counting down (like what I did above), or the normal one. The documentation I linked would do a great job at explaining it more than I do.

##
math.floor

math.floor basically converts a float into an int, or lowers it to the closes integer.

If you don’t know what integers (ints for short) are, they’re basically whole numbers. Not anything like 3.14, 5.56, 0.1166777, just 1, 4, and more. Floats are the exact opposite of ints, and if you like to be fancy, they are called “floating points”.

What math.floor does is basically lower the float to the closest integer. For example, let’s say we have 5.6 or 5.7, if we use math.floor on that it’ll return 5, removing the dot and the additional fraction.

There is also another math function that is the exact opposite of math.floor, which is math.ceil. Which returns the highest integer closest to the floating point (e.g. 5.4 > 6).

##
Percentage symbol?

As we all know, dividing a number by 60 gives us the minutes. For example, there are 300 seconds in 5 minutes. If we divide 300 by 60, we get 5, which is the minute. But what about %?

% is called “Modulus”, it is highly similar with division (/), but instead of returning the result, it gives us the remainder, which, if we use this, it gives us the seconds, but capped to 60/59 (since we don’t want the counter’s seconds to go over like 04:304).