Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I be able to track the amount of time spent?

Sorry, it's a confusing question, but I'll go into more detail in here. Would it be possible to make a NumberValue and lets set it to, for example, 600 (which would be ten minutes)

It would decrease 1 every second and when you'd leave, it would still subtract the amount of time you spent away from the game.

Example;

Value is 600, player spends 100 seconds in game, then leaves. The value is left at 500. It's been 300 seconds, the player rejoins the game and the value changes to 200 (subtracted the time the player was away)

I've tried using datastores and such to save the value, but I don't know how it would be possible to track the amount the player has spent away from the game.

Any wiki links or a simple solution (if it's not really that simple, wiki links guiding me would be appreciated)

Thank you.

1 answer

✓ Accepted answer

I think I know what you want. A cool down that continues when out of the game? Sure, use is.time to record when you can next use the whateve:

local cooldown = os.time() + 600

while wait() do
    if os.time() > cooldown then --Phone uses Autocorrect! Its super effective! Code is now incorrect!
        --stuff
    end
end

2 comments

0

Uh, what? "so.time"? Also, i wanted a value that starts at 600 but decreases by -1 each time, you gave me some code that doesn't work?

0

Sorry, os.time The joys of mobile phones autocorrect. Also, you wanted code which causes a number to count down, even when the player is disconnected. This will produce the same results, just in a different format.

This discussion is preserved as it was. New answers, comments, and votes are closed.