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: Saving Script

Previous Thread :: Next Thread 
jmr11b is not online. 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 is not online. 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 is not online. 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 is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
26 Jun 2013 04:31 PM
ahhh nobody?
Report Abuse
LittleWorlds is not online. LittleWorlds
Joined: 01 Jan 2013
Total Posts: 41
26 Jun 2013 09:50 PM
I don't know :/
Report Abuse
jmr11b is not online. jmr11b
Joined: 19 Aug 2010
Total Posts: 806
26 Jun 2013 11:30 PM
At least you tried lol
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