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
|
  |
| 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
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 20 May 2013 07:27 AM |
| What do you mean by "make it better"? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|