What is tick ?, is it usefull?

Hello there, I’m Pixeluted I see a lot of scripters using


I don’t know what is it and It’s useful?
Thank for Reading

tick() is supposes to return how many second passed since the UNIX Epoch, otherwise called 1970, I guess you can use it to mess with dates; all though there is the os.date() which is way better and let’s you have more detail to play with.

So what’s tick useful for? Well, there are a lot of use cases that you can come up with, but a one that you might encounter sometimes is: calculating how much time it would take a certain part of code to run.

local start = tick()

local cf = CFrame.new()

print(tick() - start)

For example here, we are calculating how much time it would take to create an empty CFrame (identity cframe) and assign it to a variable. The result isn’t always constant, it’s mostly random and jumps from times to others, which is why this is used to get a rough picture of what’s going, estimating an exact time is impossible.

What’s happening is, we’re storing at how many second we have started (the variable start), then let the code do it’s thing, and after that’s done, we subtract at how many second we are now, the most recent value that tick() returns, from when we started, start, to get how much time passed


What I do not understand ???

It has been 10 seconds since I replied… Read the full post in order to understand


Still do not understand ???

tl:dr : You can use tick() to calculate how much time it would take something to finish

By surrounding that thing like this:

local start = tick() --start calculating from this point

--the thing you wanna do

print(tick() - start) --prints how much time passed

OHHH so like How many long player hold the button ?

Well, what you mentionned is a calculation as well, but this one is a calculation of time.

You can see the result you got, at the end it has a e-06.
That’s scientific notation, it means 10^-6, 10 to the power of -6, which simply means add 6 decimal places to the following number, that it’s being multiplied with.

2.234e-2 for example means 2.234 * 10^-6, which is a really small number, something almost like 0,000002234.

The calculated number is super small as you can see, because everything happens very fast.

1 Like

Not how many times, but you could use it measure how long a button has been pressed for, for example…

-- lets assume the button A has just been pressed, and we want to time it

local startTime = tick()

repeat wait() until UserInputService:IsKeyDown(Enum.KeyCode.A) == false

print(tick() - startTime)

Yes I do something similiar is Correct ?

It is useful, tick() is the thing that scripters use for getting time.

Most of people using it for the Daily Reward system which is at popular games.
They save the data and check

if tick() - lastDailyRewardstick > 86400 then
      print("it been 1 day take that gift")

this tutorial should help you get a more clear understanding of tick() also, please make sure to search before posting, there are a lot of explanations out there