jmr11b
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 806 |
|
|
| 26 Jun 2013 01:46 PM |
Hey, I have been working on this save script for some time now. I just can't get it to work, I use the message as a sort of print output since you can't test Data Persistence in Solo Mode, can anyone spot an error?
sword = "Test Sword" local m = Instance.new("Message") m.Parent = game.Workspace
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() local purchased = player.PlayerGui.CharacterSelection.Knight.WeaponList:findFirstChild(sword) local ok, ret = pcall(function() return player:LoadBoolean(sword) end) if ok then if ret ~= false then purchased.Value = ret else print("Nothing to load/Boolean was False") m.Text = "Nothing to load/Boolean was False" end else Print("Error:", ret) m.Text = ("Error:" .. ret) end end)
game.Players.PlayerRemoving:connect(function(player) m.Text = "Player has left!" local purchased = player.PlayerGui.CharacterSelection.Knight.WeaponList:GetChildren() for i=1, #purchased do if purchased.ClassName == "BoolValue" then m.Text = "Boolean has been found!" local value = purchased[i] local succ, ret = pcall(function() player:SaveBoolean(sword, value.Value) end) if succ then print("Successfully Saved!") m.Text = "Successfully Saved!" else print("Saving error:", ret) m.Text = ("Saving error:" .. ret) end end end end) |
|
|
| Report Abuse |
|
|
jmr11b
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 806 |
|
|
| 26 Jun 2013 01:47 PM |
| The message always displays "Nothing to load/Boolean was False". I do change the Boolean to true when I join also. I think the problem is in the saving, it doesn't even display "Player has left!". |
|
|
| Report Abuse |
|
|
jmr11b
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 806 |
|
|
| 26 Jun 2013 04:16 PM |
Okay, that was probably too big for anyone to look over. Anyone want to scan through this?
game.Players.PlayerRemoving:connect(function(player) m.Text = "Player has left!" local purchased = player.PlayerGui.CharacterSelection.Knight.WeaponList:GetChildren() for i=1, #purchased do if purchased.ClassName == "BoolValue" then m.Text = "Boolean has been found!" local value = purchased[i] local succ, ret = pcall(function() player:SaveBoolean(sword, value.Value) end) if succ then print("Successfully Saved!") m.Text = "Successfully Saved!" else print("Saving error:", ret) m.Text = ("Saving error:" .. ret) end end end end) |
|
|
| Report Abuse |
|
|
jmr11b
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 806 |
|
| |
|
| |
|
jmr11b
|
  |
| Joined: 19 Aug 2010 |
| Total Posts: 806 |
|
| |
|