|
| 05 Feb 2014 09:07 PM |
Ok so I know the following will allow you to save the players leaderstats. I would think that you could do the same with some value that the player possesses? Like lets say I wanted to save a characters Armour so I changed out the leaderstats for a value that the character was given to begin with and when he rejoins the game. Would that be possible or does DP only work with leaderstats?
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)
|
|
|
| Report Abuse |
|
|
dodleman
|
  |
| Joined: 22 Dec 2007 |
| Total Posts: 1118 |
|
|
| 05 Feb 2014 09:21 PM |
My question is why are you posting a free model on SH and asking us a question irrelevant to it?
data persistence can be used for anything you want to save. As seen on the wiki, an example is building places in which players can globally save their buildings.
To answer, you can use DP on anything. |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2014 12:34 AM |
I'm giving you an example, there go the following script I was abiding by.
And how was the question irrelevant to it?
All I needed to know was your last sentence no need for the ignorance child. |
|
|
| Report Abuse |
|
|
dodleman
|
  |
| Joined: 22 Dec 2007 |
| Total Posts: 1118 |
|
|
| 06 Feb 2014 01:07 AM |
Child? You could have atleast attempted to make your own script as the example.
Life is potatoes to me |
|
|
| Report Abuse |
|
|
iValianT
|
  |
| Joined: 21 Aug 2010 |
| Total Posts: 58381 |
|
|
| 06 Feb 2014 01:17 AM |
| This script has nothing to do with what you want to achieve |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2014 08:58 AM |
I'm new to data persistence, I haven't been on this game in over a year. So calm down for me using an example to work with. And this script has everything to do with what I want to accomplish?
It saves a players leaderstats upon leaving and loads them upon entering. I simply wanted to know if I could use different values not parent to leaderstats. And from what I've heard you can. |
|
|
| Report Abuse |
|
|