Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can this tick clock work?

Hi,

I was wondering how to make a tick clock because I want to count time locally not based on server lag or anything. I don't know how to count in tick so basically I want to make a stopwatch which ends at the players death and starts basically at the time I want it to. I also want the time to go onto a gui and be in a colon format like (3(m):05(s):04(ms).

Would it look something like this? (This wont work)

local startTime = tick()

while wait(1) do -- This wont work because there is still a wait inside which doesnt count globally.
currentTimeAmount = tick()
textLabel.Text = currentTimeAmount -- I know this is wrong because i didnt declare a variable but i need -- to be quick
end

-- I'm stuck on rounding and formatting the timer in the way I want it to be.
-- I'm also stuck on stopping at death but I know the event to use is humanoid.Died.

Thanks

1 comment

0

The wait() delta is useful.

1 answer

✓ Accepted answer

You can try something like this

local i = 0;
local unbreak = true;
yourPlayer.Humanoid.Died:connect(function()
	unbreak = false;
end);
while unbreak do
	i = i+wait(1);
	timer.Text = string.format("%.1d:%.2d:%.2d", i/3600, (i/60)%60, i%60);
end;

You'll need to declare timer and yourPlayer, and you'll need to make this code run when you need it to.

2 comments

0

Doesn't this use wait? Thanks but I want a stopwatch that isn't effected by lag at all, I want something that

0

It won't. I've made it use the delta - The most lag you're going to get from it is miliseconds worth of lag from the format function accumulating over minutes or hours of running.

This discussion is preserved as it was. New answers, comments, and votes are closed.