GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
|
| 16 Sep 2011 09:27 AM |
Who can fix the problem?
KEY = "Stage" -- The Save Name Of The Score NAME = "Stage" -- The Name Of The Score
Score = player.leaderstats:findFirstChild(NAME) game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady()
local succ,ret = pcall(function() player:LoadNumber(KEY) end) if succ then if ret ~= 0 then
player.leaderstats.Score.Value = ret
end
end
end)
game.Players.PlayerRemoving:connect(function(player) local succ,ret = pcall(function() player:SaveNumber(KEY,Score) end)
end)
Thanks! |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
| |
|
|
| 16 Sep 2011 09:37 AM |
You obviously do not know how pcall works.
The 'ret' variable is not what you think it is. Well, the succ variable is a boolean. If there is an error inside the pcall, it equals true, if not it equals false. The SECOND variable, is the actual error. So, if succ was true, it would be nil, if not, the actual error.
Anyways, you don't _NEED_ to use pcall for Data Persistence anymore, it was only used back when Data Persistence was first released.
Fixed version:
KEY = "Stage" -- The Save Name Of The Score NAME = "Stage" -- The Name Of The Score
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() if player:LoadNumber(KEY) ~= 0 then player.leaderstats.Score.Value = player:LoadNumber(key) end end end) game.Players.PlayerRemoving:connect(function(player) Score = player.leaderstats:findFirstChild(NAME) player:SaveNumber(KEY,Score) end)
-Like an __AWESOME__ boss |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2011 09:38 AM |
Oops, fail, change:
player.leaderstats.Score.Value = player:LoadNumber(key)
to:
player.leaderstats.Score.Value = player:LoadNumber(KEY)
and change:
player:SaveNumber(KEY,Score)
to:
player:SaveNumber(KEY,Score.Value)
-Like an __AWESOME__ boss |
|
|
| Report Abuse |
|
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
|
| 16 Sep 2011 09:40 AM |
Yes i edited it fmo the wiki
THANKS! |
|
|
| Report Abuse |
|
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
| |
|
|
| 16 Sep 2011 09:40 AM |
Umm, no problem.
-Like an __AWESOME__ boss |
|
|
| Report Abuse |
|
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
|
| 16 Sep 2011 09:52 AM |
Sorry that i need to say it but it still dont work:
KEY = "Stage" -- The Save Name Of The Score NAME = "Stage" -- The Name Of The Score
SCORE = player.leaderstats:findFirstChild(NAME) game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() if player:LoadNumber(KEY) ~= 0 then SCORE.Value = player:LoadNumber(KEY) end end end) game.Players.PlayerRemoving:connect(function(player) Score = player.leaderstats:findFirstChild(NAME) player:SaveNumber(KEY,Score) end)
|
|
|
| Report Abuse |
|
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
| |
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
| |
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
| |
|
|
| 18 Sep 2011 04:25 AM |
KEY = "Stage" -- The Save Name Of The Score NAME = "Stage" -- The Name Of The Score
SCORE = player.leaderstats:findFirstChild(NAME) game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() if player:LoadNumber(KEY) ~= 0 then SCORE.Value = player:LoadNumber(KEY) end -- Take this end out end end) game.Players.PlayerRemoving:connect(function(player) Score = player.leaderstats:findFirstChild(NAME) player:SaveNumber(KEY,Score) end)
All I'm going to say is, you had an extra end... |
|
|
| Report Abuse |
|
|