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 Persistance Help?

Previous Thread :: Next Thread 
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
08 Jul 2011 09:38 AM
I have been working on this Simple data persistance script for players. All you would have to do is put it in the workspace and it would save your scores. However its not working. Could anyone help?
------------------------------------------------------------------------------------------
function onPlayerEntered(player)
wait()-- Give the game a moment to find the player instead of shooting instantly
player:WaitForDataReady() -- Gotta have this
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren() -- Were going to find some scores.
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Value) -- This looks for the score
wait() -- Wait for the score to load.
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end

function onPlayerLeaving(player) -- We gotta fire this before the player leaves.
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren() -- Targeting the scores before the player is gone
for i = 1,#score do
player.leaderstats:findFirstChild(score[i]):SaveNumber(score[i].Name,score[i].Value) -- Saving the score.
end
end
end

game.Players.ChildAdded:connect(onPlayerEnterd)
game.Players.PlayerRemoving:connect(onPlayerLeaving)

------------------------------------------------------------------------------------------
Does anyong know the problem? And yes the output isnt saying anything.
Report Abuse
myrco919 is not online. myrco919
Joined: 12 Jun 2009
Total Posts: 13241
08 Jul 2011 09:41 AM
[ Content Deleted ]
Report Abuse
61352151511 is not online. 61352151511
Joined: 30 Nov 2009
Total Posts: 8094
08 Jul 2011 09:52 AM
player:WaitForDataReady() -- Gotta have this
if player.DataReady then

Whats the point of the second line. The first one will wait to do the rest of the script until the Data is ready

~ Mitch ~
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
09 Jul 2011 03:02 PM
*bump*
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
09 Jul 2011 08:57 PM
*Another bump Q_Q*
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
09 Jul 2011 09:57 PM
T_T
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