|
| 21 Sep 2016 02:56 PM |
Is it possible to change Data Persistence to a Data Store?
The Data Persistence I'm using is:
function onPlayerEntered(player) wait()-- Change to wait for player longer. player:WaitForDataReady() repeat wait() until player:FindFirstChild("leaderstats") if player.DataReady then if player:findFirstChild("leaderstats") then local score = player.leaderstats:GetChildren() for i = 1,#score do local ScoreLoaded = player:LoadNumber(score[i].Name) wait() if ScoreLoaded ~= 0 then score[i].Value = ScoreLoaded end end end end end
function onPlayerLeaving(player) if player:findFirstChild("leaderstats") then local score = player.leaderstats:GetChildren() for i = 1,#score do player:SaveNumber(score[i].Name,score[i].Value) end end end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerLeaving)
~ Thanks for playing. Come again. |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Sep 2016 03:00 PM |
| When I go to switch Data Persistence to a Data Store, won't I lose the DP stats? |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:01 PM |
Almost certain you will, but it'll be better in the long run using something that isn't deprecated
|
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:03 PM |
if player:LoadNumber(junk) ~= default then --save old data end |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:03 PM |
I don't think the people who have been using the game would appreciate lost progress. I've been using DP to track race wins, so if people who have won over a hundred races loses that, that's obviously an issue....
|
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Sep 2016 03:05 PM |
| How would I use that? Input that to the DP, DS, or it's own script? |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:05 PM |
you could save the existing data to a datastore, when the player joins use datapersistence to retrieve their wins or whatever, then insert that into a datastore. if you're doing this for a game then just post something like "join within 3 weeks unless u want to lose your stuff blah blah blah" so that people who care about their wins can join, have them save over to datastores, and then after that period remove datapersistence and convert solely to datastores.
|
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:08 PM |
| During the 3 weeks that both dp and ds are in the same server, would they still be able to earn more (in this case) wins and it would continue to convert from dp to ds? |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:09 PM |
when the player initially joins the game for the first time when this is added, load it from datapersistence and generate a key and that value within a datastore. from that point forward, every time they gain a win check for that key within your wins datastore, and if it exists update it and if it doesnt create it. don't save anything else to datapersistence, it will only hinder you.
|
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:13 PM |
Alright, so, you said some words there, but none of that means anything to me, to be honest.
Like, I'll be honest, that I'm a complete Lua scrub. I understand like some of the if hit then change color and like physical changes. I get lost on the functions and stuff like this.... :[ |
|
|
| Report Abuse |
|
|
| |
|