I'm kinda stuck. If you could answer on what to delete/add, that would be highly appreciated.
I'm trying to make a countdown, and when the countdown reaches 0, the countdown waits 5 seconds and then resets/restarts the countdown.
The script is placed inside of the TextLabel.
local time = 150 --The time it starts at.
for i = 1, 150 do
wait(1)
time = time - 1
script.Parent.Text = tostring(time)
end
script.Parent.Text = "Game over."
if script.Parent.Text == 0 then
wait(5) script.Parent.Text = "150"
end
This is all I have so far. Any help would be appreciated!
So What I would say is don't put the code in a for loop but a while true loop if you want it to go on forever
Old Code Here is what you originally have
local time = 150 --The time it starts at. for i = 1, 150 do wait(1) time = time - 1 script.Parent.Text = tostring(time) end script.Parent.Text = "Game over." if script.Parent.Text == 0 then wait(5) script.Parent.Text = "150" end
Now if you wat the code to go on forever here is a method that you can use to do it
local startTime = 150 --The time it starts at. local currentTime = startTime-- Makes it so only one value has to be changed to change the time length while true do script.Parent.Text = tostring(currentTime) --Set the text equal to the time if currentTime<= 0 then--check if its zero script.Parent.Text = "Game over." wait(5) currentTime = startTime else--if not subtract one currentTime currentTime time - 1 end wait(1) --wait one second end