Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does the "tick()" function do?

Asked by 5 years ago

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

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 User#25115 0 — 5y
2
Could you explain what exactly is not clear? It already looks like it's explained it as fully as possible. User#25115 0 — 5y
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)." namespace25 594 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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

Ad
Log in to vote
0
Answered by 5 years ago

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!

Answer this question