generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Data Persistence question.

Previous Thread :: Next Thread 
matt1020304050 is not online. matt1020304050
Joined: 24 May 2008
Total Posts: 4475
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 is not online. 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
matt1020304050 is not online. matt1020304050
Joined: 24 May 2008
Total Posts: 4475
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 is not online. 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 is not online. 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
matt1020304050 is not online. matt1020304050
Joined: 24 May 2008
Total Posts: 4475
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image