Alternatives to tick() and time()

I’m making a timing system in my game and I tried using tick() and time() but they were super inaccurate and I can’t find anything better to use.

1 Like

You can use os.clock() and os.time()

Though, what are you doing?
If you do this:

local time = os.clock()
wait(1)
print(time) -- big number

It won’t work, it must be this way;

local time = os.clock()
wait(1)
print(os.clock() - time) -- 1

I never had an issue with tick(), can you please explain what errors/issues are you getting? It should be fairly accurate though.

I’m making a basketball shooting system for this guys game and u have to time the meter when it gets to the top so i check the tick() between the time the person first started holding the shoot button and when they ended holding it and its been very inaccurate.

Can you provide the code as to see how you are handling this?

I already fixed the issue by using something else but I’m trying to figure out an alternative for uses in the future.

os.clock() is intended for benchmarking and is extremely accurate, I don’t see how that would be an issue

2 Likes

Don’t use tick, use time. Use os.clock for benchmarking or if you need to track time in a non-game-runtime environment (e.g. a plugin). [source]

4 Likes