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
 

Data Persistence Load/Save Script

Previous Thread :: Next Thread 
tidus019 is not online. tidus019
Joined: 12 Nov 2008
Total Posts: 132
20 May 2013 06:44 AM
Hello, I've wrote this script, and I wonder if there's anything that can be done better, since it's the first time I work with Data Persistence. It works though, I just checked it out :D

function onPlayerEnter(player)
player:WaitForDataReady()
print(player.Name .. " data is ready")
local DataExists
if not pcall(function() DataExists = player:LoadBoolean("DataExists") end) then
if pcall(function() SaveBoolean("DataExists",true) end) then --Create Bool
print(player.Name .. "DataExists created")
else
onPlayerEnter(player) -- Recursive step if saving fails.
end
else -- Data already exists
DataExists = player:LoadBoolean("DataExists")
end
end

game.Players.PlayerAdded:connect(onPlayerEnter)
Report Abuse
tidus019 is not online. tidus019
Joined: 12 Nov 2008
Total Posts: 132
20 May 2013 07:03 AM
By the way, is it necessary to use WaitForDataReady() more than once? If my "DataExists" is true, can I assume the Persistant Data remains ready?
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
20 May 2013 07:27 AM
What do you mean by "make it better"?
Report Abuse
tidus019 is not online. tidus019
Joined: 12 Nov 2008
Total Posts: 132
20 May 2013 07:35 AM
For example, maybe I added something useless or something could be done more efficiently.
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
20 May 2013 07:38 AM
Your script has alot of functions that makes your game much more secure. Lol. Like pcall, and re-doing the same player entered method if it fails.
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