nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 02:16 PM |
Can someone help fix this?
function savescore() player = script.Parent.Parent.Parent.Parent player:WaitForDataReady() stats = player:FindFirstChild("leaderstats") speedx = player:findFirstChild("Speed") healthx = player:findFirstChild("Health") levels = stats:FindFirstChild("Level") xps = stats:findFirstChild("XP") golds = stats:findFirstChilld("Gold") player:SaveNumber("level",levels.Value) player:SaveNumber("xp", xps.Value) player:SaveNumber("gold", golds.Value) player:SaveNumber("speed", speedx.Value) player:SaveNumber("health", healthx.Value) if game.Lighting:findFirstChild("GUI"..player.Name.."GUI") then player:SaveInstance("Shop",game.Lighting:findFirstChild("GUI"..player.Name.."GUI")) end m = Instance.new("Message",player.PlayerGui) m.Text = "Game Saved!" game.Debris:AddItem(m,2) end |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 02:18 PM |
| idk what the error is because you can't use data persistence in edit mode |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 26 Nov 2011 02:19 PM |
You never called the function...
~Myrco; Music lover, nederlands/dutch and a scripter |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 02:20 PM |
| Yes I did in the script it is called from when the TextButton is clicked. |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 02:20 PM |
| script.Parent.Save.MouseButton1Click:connect(savescore) |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 26 Nov 2011 02:28 PM |
And both codes are in the same script, right?
(I'm too lazy to read it trough,, because I'm currently foruming in Scripters and soon going to do something else).
~Myrco; Music lover, nederlands/dutch and a scripter |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
| |
|
|
| 26 Nov 2011 02:29 PM |
DataPersistence doesn't work on Edit mode. (WaitForDataReady will wait forever)
I'm sorry but you will have to test it online. |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 02:43 PM |
| No duh! That's what I'm asking for. I tested it and it won't work. |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
| |
|
|
| 26 Nov 2011 03:15 PM |
| It looks fine to me. Post your data loading function also. |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 03:18 PM |
| I know the save one doesn't work because the message doesn't come up but I'll post the whole script... |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 03:20 PM |
function savescore() player = script.Parent.Parent.Parent.Parent player:WaitForDataReady() stats = player:FindFirstChild("leaderstats") speedx = player:findFirstChild("Speed") healthx = player:findFirstChild("Health") levels = stats:FindFirstChild("Level") xps = stats:findFirstChild("XP") golds = stats:findFirstChilld("Gold") player:SaveNumber("level",levels.Value) player:SaveNumber("xp", xps.Value) player:SaveNumber("gold", golds.Value) player:SaveNumber("speed", speedx.Value) player:SaveNumber("health", healthx.Value) if game.Lighting:findFirstChild("GUI"..player.Name.."GUI") then player:SaveInstance("Shop",game.Lighting:findFirstChild("GUI"..player.Name.."GUI")) end m = Instance.new("Message",player.PlayerGui) m.Text = "Game Saved!" game.Debris:AddItem(m,2) end
function loadscore() player = script.Parent.Parent.Parent.Parent if player.Loaded.Value == false then player.Loaded.Value = true player:WaitForDataReady() local level = player:LoadNumber("level") if level ~= 0 then player.leaderstats.Level.Value = level end local xp = player:LoadNumber("xp") if xp ~= 0 then player.leaderstats.XP.Value = xp end local money = player:LoadNumber("gold") if money ~= 0 then player.leaderstats.Gold.Value = money end local speed = player:LoadNumber("speed") if speed ~= 0 then player.Speed.Value = speed end local health = player:LoadNumber("health") if health ~= 0 then player.Health.Value = health end gui = player:LoadInstance("Shop") gui.Parent = player.PlayerGui gui:clone().Parent = game.Lighting m = Instance.new("Message",player.PlayerGui) m.Text = "Game Loaded" game.Debris:AddItem(m,2) end end
script.Parent.Load.MouseButton1Click:connect(loadscore) script.Parent.Save.MouseButton1Click:connect(savescore) |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 03:22 PM |
| Are "Save" and "Load" parts or clickdetectors? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 03:27 PM |
WaitForDataReady will wait forever on edit or play solo.
Just incase you are testing it on that. |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 03:30 PM |
| reactor I'm not and it is a gui |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2011 03:30 PM |
| Have you put it in a localscript or normal script? |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
| |
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 26 Nov 2011 05:06 PM |
| What adds the leaderstats and when? |
|
|
| Report Abuse |
|
|
br45entei
|
  |
| Joined: 06 Nov 2010 |
| Total Posts: 1058 |
|
|
| 26 Nov 2011 05:13 PM |
| in the pcall section, make it output to a message in your player.Playergui, that way you can see the output in-game. |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 05:42 PM |
I figured it out!! I added an extra l where it says findFirstChild("Gold")
I said findFirstChilld("Gold") -_- |
|
|
| Report Abuse |
|
|
nPwn
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 3197 |
|
|
| 26 Nov 2011 05:42 PM |
| @br45 I totally did that to figure it out before I saw you say that XD |
|
|
| Report Abuse |
|
|
br45entei
|
  |
| Joined: 06 Nov 2010 |
| Total Posts: 1058 |
|
| |
|