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

What does the "tick()" function do?

I have tried looking at the wiki but it doesn't explain it well enough for me to understand.

4 comments

0

It "Returns the amount of time in seconds since the UNIX epoch (January 1st, 1970) on the current local session’s computer. It is precise to the nearest millisecond (0.001s)." ~  https://developer.roblox.com/articles/Built-in-Functions-and-Variables/Roblox#tick

2

Could you explain what exactly is not clear? It already looks like it's explained it as fully as possible.

0

"Returns the amount of time in seconds since the UNIX epoch (January 1st, 1970) on the current local session’s computer. It is precise to the nearest millisecond (0.001s)."

2 answers

✓ Accepted answer

If you did:

print(tick())

It would return a large number value that is the number of seconds that have passed since January 1st, 1970. It is just a way to tell the time of the local session's computer. It is precise to the nearest millisecond (0.001s).

The number would probably look something like this: 1551206971.4111

tick() returns the number of seconds as a number since the UNIX Epoch, which is January 1, 1970.

Extra

Sometimes you might not want the decimal places, so I provided a function to return the rounded version of tick():

function tickRounded()
	local seconds = tick()
	return math.floor(seconds)
end

Running tickRounded() would return the number of seconds since January 1, 1970 as an integer instead of a decimal.

Hope this helps!

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