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

How would you make a DataSaving total time played?

Asked by 5 years ago

I want to add a total time played to my game but there's an issue w/ the fact that time played scripts have an starting value of 0, meaning it doesn't save and just resets each time.

0
Hmm, this is very tricky. Try reading up on this and see if you get anything. I think the datastore just isnt working. Got a script btw? https://developer.roblox.com/articles/Saving-Player-Data Rynappel 212 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

That should be very easy. First things first you have your Leaderboard with a new Numbervalue called TimePlayed You dont set the value doe!

local timeplayed = Instance.new("NumberValue")
timeplayed.Parent = leaderstats

After that you just need a function that adds +1 every second to the timeplayed value. You can do that in a diffrent script or in the leaderboard script. we're doing it in the leaderboard script, because we already have the player defined ( If you already have a leaderboard which I assume with the PlayerEntered Event and the player parameter )

while wait(1) do
    player.leaderstats.timeplayed = player.leaderstats.timeplayed + 1
end

Of course you need to fix some names around and add your own stuff because you didnt gave us any scripts whatsoever, But thats the general way of doing it.

QUESTION: Why dont you remove the starting value of 0 ? wouldnt it fix it for you?

Ad

Answer this question