Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make timer to save into data store service?

Asked by 3 years ago

So I'm making an AFK game and I have the script working:

function onPlayerEntered(newPlayer)

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local secs = Instance.new("IntValue")
    secs.Name = "Time Played"
    secs.Value = 0


    secs.Parent = stats

    stats.Parent = newPlayer

    while true do
        wait(1)
        secs.Value = secs.Value + 1
    end
end

game.Players.ChildAdded:connect(onPlayerEntered)

But somehow I can't figure out how to store it, anyone can tell me how or why?

0
You can just save the data once the player leaves the game. Also use this dev forum page: https://developer.roblox.com/en-us/articles/Data-store thecelestialcube 123 — 3y

Answer this question