How to make timer to do two different timers (not at the same time) and repeat forever

I made a script that displays the seconds left before a tram departs but after that countdown ends, I want the script to display the seconds remaining before the tram returns and I would like it to repeat the countdowns forever.

The image above shows the timer after the countdown ends and it doesn’t repeat or anything. Can someone help me with this?

5 Likes

Use while loop
Also please tell us the script you are using for tram countdown currently, so that we can help better.

2 Likes

I’ll give you a short example of what a script like that would look like.

ex:

-- feel free to customize the variables at your will
local depart_time = 10
local return_time = 20

local text_label -- insert text label for num

while wait(1) do
    if depart_time > 0 then
        depart_time = depart_time - 1
        text_label = tostring(depart_time)
    elseif return_time > 0 then
        return_time = return_time - 1
        text_label = tostring(return_time)
    else
        depart_time = 10
        return_time = 20
        text_label = tostring(depart_time)
    end
end
2 Likes

Sorry for late reply, I made this topic at night in my area and I had to sleep.
This is the script that I currently use:

local Seconds = 30

for i = 1,Seconds do
Seconds = Seconds - 1
script.Parent.SurfaceGui.TextLabel.Text = Seconds
if Seconds < 11 then
end
wait(1)
end

1 Like

Tried using the script but it somehow doesn’t work and I even tried changing stuff around to see if it works but no.

2 Likes

Why doesn’t it work? Was there an error, or did it just not work as intended?

2 Likes

It didn’t work for me at all. I’m not sure if I am doing something wrong.

1 Like

The problem is with your surface GUI then, could you show me how you structured it?

1 Like

This is how I structured it

1 Like

Silly me… try this.

-- feel free to customize the variables at your will
local depart_time = 10
local return_time = 20

local text_label -- insert text label for num

while wait(1) do
    if depart_time > 0 then
        depart_time = depart_time - 1
        text_label.Text = tostring(depart_time)
    elseif return_time > 0 then
        return_time = return_time - 1
        text_label.Text = tostring(return_time)
    else
        depart_time = 10
        return_time = 20
        text_label.Text = tostring(depart_time)
    end
end
1 Like

It’s the same exact script and it still doesn’t work for me at all.

local Seconds = 30

while task.wait() do
	for i = 1,Seconds do
		Seconds = Seconds - 1
		script.Parent.SurfaceGui.TextLabel.Text = Seconds
		if Seconds < 11 then
		end
		wait(1)
	end
end

you can use this i think, also you can write true instead of task.wait(), but i wrote task.wait because i am allergic to while true do

It works but I want two different timers (not at the same time) and repeat forever.

What do you mean “two different timers” ?
Do you mean
Two timers that works differently each other?
If that is right, you can add a wait(seconds) before the while loop. so it delays the timer starting.