How do you create a timer that counts a players time?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a timer that counts up like this 00:00.00
  2. What is the issue? Include screenshots / videos if possible!
    I can’t seem to make this happen.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked on youtube and the developed hub but I couldn’t find a topic like this.
6 Likes

So you want to make a time counter for every, or just the local player, and from the start or just on a event

2 Likes

I have a few inquiries:

  1. Do you want a timer for each player individually? (Not a global timer)
  2. Where do you want to show this timer? On a GUI for just that player to see, or somewhere else?
  3. When do you want it to start?
3 Likes
  1. Is the timer being used for how long the player is in-game (join to leave) or is it the server uptime, or something else?
  2. When will this timer be starting and when will it be ending?
  3. How will you be displaying the timer?
  4. What is the point of this timer?
2 Likes

Local player. I am making an obby game so I want players to be timed when they start the obby.

1 Like

So it is easy, create a local script inside of a label

And make a normal script, in the server script service

The server script
Im mobile so i dont have the lua characters
game.Players.PlayerAdded:Connect(function(plr)
local stat = Instance.new(“IntValue”)
stat.Name = “time”
stat.Parent = plr
while wait (0.01) do
stat.Value = stat.Value + 1
end
end)

1 Like

But question. How would I make it count up in like intervals of 00:00.00?

Yea i was wrong, i just fixed it

put this under a local script inside of a textlabel:

local milisecond = 0
local second = 0
local minute = 0
local hour = 0
while wait(0.01) do
	if milisecond >= 60 then
		milisecond -= 60
		second += 1
	end
	if second >= 60 then
		second -= 60
		minute += 1
	end
	if minute >= 60 then
		minute -= 60
		hour += 1
	end
	milisecond += 1
	script.Parent.Text = hour..":"..minute..":"..second.."."..milisecond
end
5 Likes

Yeah it would take me a lot more time to make than this dude

thanks for the compliment :smile:

I would recommend against this method, as using wait(0.01) could cause problems. wait() is known to have problems with it not correctly waiting for the small amount of time like 0.01. I suggest you re-implement this solution with something like tick().

4 Likes

U probably type like a godzilla lol

well this doesnt have any problems at all, I just tested it. it doesnt take up much memory and doesnt cause lag. It’s a fully functioning timer.

Well how many players did you have in your testing? How many things were going on? I’m saying that I myself have had problems using wait(), and I am simply suggesting that tick() is a safer solution that can have more decimal places if ever necessary in the future, and it’s usage is actually meant to count time in seconds.

2 Likes

Then we could also use os.time if it comes to secs

even so, its local so it wouldnt cause any lag as it doesnt run other peoples timer. It does not have any problems at all, I get that in different ways tick() can be better but for this its perfectly fine and as for “wait having problems with small numbers” it with something like this. It only has problems with small numbers if you’re having a lot of things running from it within that short time.

There are a lot of ways you can do that, an option would be using os.time

Or creating a timer by yourself.