How does the "tick()" function actually work?

I might be dumb, but what is the

  "tick()"

function REALLY used for in Roblox Studio?
I know I’ve seen that it’s useful for cooldowns and things like that, but I don’t understand how it works.

1 Like


feel like the documentation explains it well

1 Like

I tried to understand it through the API. I created the infinite loop and looked at the Unix website, I understood that much. But how can it be useful currently? For example, does it start ticking the moment the code is executed?

Like
Local thetick = tick() - STARTS TICK

Rest of code
If tick() - thetick… - ends the tick

it returns how much time has elapsed (in seconds) since the first january of 1970, thats it, nothing else

So if the player used an ability at 13:10 and that time is greater than that, it will be executed and will it go on cooldown?

did not understand any of that ngl

tick() doesn’t execute anything if that’s what you’re asking, it just returns a number

Could you give a very simple example (Code or no code.), just so I can be sure of what I’ve understood so far, or so I can understand?

local unix = tick() -- does absolutely nothing besides give you this number
-- mysterious unit of time passes
local diff = tick()-unix -- how much time has passed since the last measurement
-- TICK ISNT DOING ANYTHING HERE, ITS JUST GIVING ANOTHER NUMBER

ooohhh i think i understand for now.
thanks

You’re probably better off avoiding tick().

If you’re looking for a time difference during runtime, use time().

If you’re looking for benchmarking, use os.clock().

If you’re looking to sync a timestamp between server and client, use workspace:GetServerTimeNow().

The Roblox Learn YT channel made a great video going over all these use cases and more.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.