Hey, I’m trying to make a round timer for my FPS game. A UI that displays a timer until the round ends. I don’t need to have to select a random player for a killer, or something like that. Just a normal Round system that counts down till it’s done. How can I find a perfect Tutorial?
Have you tried looking on YouTube - or other answers on this forum?
Realistically, for a very basic system all you’d need is something like this:
local x = 10 -- some number
for i=1,x do
wait(1)
some_Gui.Text = tostring(i)
end
Or similar, you could use any loop.
I’m pretty sure there are modules for more complicated systems though.
1 Like
I would probably write it somewhat differently, but as you say, any form of loop works fine.
function updateUI(timeLeft)
-- Code to format the time left into MM:SS:sss
end
local roundTimeLeft = 60 -- Reset timer
repeat
roundTimeLeft -= task.wait(1) -- Subtracts the amount of milliseconds passed
updateUI(roundTimeLeft)
until roundTimeLeft <= 0
Hey, if you’re using this as a server timer instead, you can make this in the server:
local roundTime = 100 -- seconds for example
function startRound()
for i = 1, roundTime do
wait(1)
roundTime -= 1
game.ReplicatedStorage.AnyRemote:FireAllClients(roundTime)
if roundTime == 0 or roundTime < 1 then
roundTime = 100 -- Restarting the round, however you can do whatever.
startRound() -- Restarts timer
break -- ends the current loop
end
end
end
On the client:
game.ReplicatedStorage.AnyRemote.OnClientEvent:Connect(function(T)
gui.Text = "Time Left: " .. tostring(T) .. "s"
end)
The script does not work for some strange reason