Stun time countdown

Do I while loop a wait() or is that inefficient? What can alternative is there that results in decent precision to prevent abnormalities?

Use a different method, RunService.Heartbeat, for instance, in combination of a specific code structure that functions like a timer would work better. This structure consists of os.clock() or anything similar that goes.

2 Likes

Also I have another question, should I store the stun value in a Value or script table?

I don’t think there is a right answer here, it’s subjective and objectively depending on a number of factors on how you want this to conduct.

1 Like

Do you think ping would affect the values changing serversided more or the scripts being delayed more?

The ping only interferes the network detail, not the memory. Server will be hit heavily if the function was expensive. In this case, it isn’t. Execution would go as per usual.

1 Like

The heartbeat and os.clock() only works in integers for me, but if you use small numbers like 0.1 then it doesn’t work?

I’d suggest using tick() for this purpose. It’s similar to wait(), but is a whole lot more reliable. Here’s another thread with info on how to use tick().

1 Like

Thanks. Sadly, I’ve already made my own system that utilises the delta of each frame to keep the wait time on track and now it’s decently accurate. I’m currently using 0.1 seconds for each countdown step.

I see you’ve found your solution already but just wanted to mention that I’ve also posted a stun handler module. It is simple to use and pretty efficient. You can check it out whenever you have time. :+1:

1 Like