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 )
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!