How to make a Timer Gui

Im making a boss battle’s game, basically i want it so that when everyone is in the lobby (not when there are remaining player’s fighting the boss) a timer gui will pop up on everyone’s screen, and will slowly go down until the second’s reaches 0, but i do not know how i can do this.

I want the timer gui to have seconds and milliseconds, (Ex. 3.45).

Also when the second’s reach 0, it will choose a random boss and teleport every player to the boss’s map

1 Like

Create a simple countdown loop and variable with the amount of time you want which decreases the variable slightly every loop (add task.wait(0.05) for example, can be anytime or whatever is accurate) display the number on the GUI, repeat it until the timer is = 0 then use math.random to randomly select a boss, then teleport. It should be pretty simple.

1 Like

Make a Textlabel in StarterGUI

add a localscript in the screengui

put

local Countdown = game.StarterGUI.ScreenGUI.TextLabel

for i = (Number), 1, -1 do

Countdown.Text = "Intermission" ...
wait (1)
end

tell me if there are errors

2 Likes

That wont do what he want. He also wanted to know how to make it with MS and a random teleport.

Is this only for the second’s or also for the miliseconds?

use os.clock (30 caractersssssssssss)

I do not know how that works (30 chmacters)

wait neverminded run service delta time would be better

I also do not know how to use that either.

https://developer.roblox.com/en-us/api-reference/event/RunService/Heartbeat

I dont really got it clear, i understand more on code examples that contain that parameter inside it.

local Time = 0
game:GetService("RunService").HeartBeat:Connect(function(DeltaTime)
    Time += DeltaTime
end)

delta time is just the time since the last hearbeat

Ohhh i seem to understand now, thanks ill see what i can do with this.

Now there’s something that i do not know what to do, the timer text appears different on every player’s screen which is because the player is joining later than the other player, how could i fix this

only one timer should exist on the server. the server should then update a number value in replicated storage and then the clients update their text every renderstepped.

So the client send’s a remote event to the server to update the number and then the client updates the timer’s text is that right?

no the server handles the timer and the clients render the timer

Use os.clock() an example would be:

function timer(textLabel, seconds)
    local startTime = os.clock()
    
    while os.clock() - startTime <= seconds do
        textLabel.Text = math.floor(os.clock() - startTime)
    end
end

Should work with ms if you time it right.