Does someone know how to make a better timer?

So i have made a report feature for a game that uses wait(), but as you know it isn’t the best out there since players can easily bypass it.

Is there a better way to like instead of using wait(300) you could use that players real world time, and make them actually wait 5 minutes.

1 Like
local timer = tick() + 5*60 --5min from now

RunService.HeartBeat:Connect(function()
    if(tick() >= timer)then
        --Times Up!
    end
end)

Can i use it with UI objects? so like if the player leaves it will still be locked before the 5 minutes pass, or do i have to use a data store

You should use a repeat loop instead.

If you put any timer on the client, then the code running that timer will shutdown when the client leaves. Since its only 5min you could keep a record on the server in a script somewhere incase they come back.

So for this method i have to use DataStores right?

For the same server no, for other servers yes. Also client waits are pointless because exploiters can modify their client.

2 Likes

Depends really. If its 5min regardless if they are in the game or not, then just have a script with a variable on the server that holds the info. If you want the 5min to resume when the client comes back then you’ll need to keep track of how much time the player has actually waited (not including when they out of the game), in which case yea you need to store the waited amount in a datastore and retrieve it when they come back.

Oh alright thank you very much!