How would I handle fire rate correctly?

Hello everyone,

I’m trying to make a fire rate system for a tower defense game that every seconds let’s say the turret fire ones.

I’m not sure how to make it accurate and not stressful on the server and without using methods that would yield the script, any help?

1 Like

Keep track of the time that the turrets have been fired by getting the time (tick(), time() or os.time()), then check the elapsed time (now - timestamp) since that occured, along with any other conditions needed for them.

should I use .Heartbeat to check it continuously or is there a better method?

For this type of method, probably if you plan to check every frame until they are ready to fire again, but would most likely depend on how you would want to handle them in the first place.

1 Like

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