Client Sided Timer

Im in the process of making a cutscene system for my game, and it is almost done! But before it is finished, I need to add a client sided timer so I can do the correct calculations on the client side to play the animations and move the camera correctly.

I need this timer to be consistent because I use Bezier Curves for my scene system and they have lifetimes described in seconds. How should I approach this?

2 Likes

use tick() function or os.time()

2 Likes

Maybe try using for loops?

for i = 25, 0, -1 do -- 25 is the amount of time to wait in seconds
	-- Inside the cutscene (the code here will repeat again and again for 25 seconds)
end

-- Code after the cutscene
2 Likes

The most precise option you have for timekeeping is os.clock which returns a float number related to the CPU time of the current client. Using the code below you can see how accurate os.clock is:

local start = os.clock()
while task.wait() do
	print(os.clock()-start)
end
2 Likes

does roblox allow os.clock()? I thought I heard somewhere that it wasn’t allowed

It does, both on the server and client. Using os.clock on the client is also a method of fingerprinting because devs can subtract it from the current time and get a constant number that can be traced to the current client:

print(tick()-os.clock()) --this value remains constant for a specific client(up to 5 decimal points that is)
1 Like

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