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

How does tick() work?

Asked by 9 years ago
 So i found this little segment that belongs to a sword script and it is suppose to make it so that you cannot slash more than once in a single slash to avoid collisions with other parts of the Character model  but i am confused. If lastclick is always equal to tick() wont delta time be always equal to 0?
lastclick=tick()
tool.Activated:connect(function()

local clickdelta   =   tick() - lastclick
if clickdelta   >    1 then
 lastclick   =    tick()

end
)

1 answer

Log in to vote
0
Answered by 9 years ago

tick() works on UNIX time which is the number of seconds that have passed since January 1, 1970. By using tick(), it'll return that number.

What that program is doing, is that it's using tick() to get the number of seconds that have passed since the last click. Basically, it only allows you to use the sword after 1 second of its previous use.

No, lastclick won't be the same as tick() because after 1 second, tick() will return a time 1 second ahead of lastclick, that way, you can check how much time has passed between 2 points in a program or something of that sort.

Hope this helped!

2
Bro i love your explanation when you mentioned January 1 1970 that was deep yo. threatboy101 2 — 9y
Ad

Answer this question