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: Leaderboard Save

Previous Thread :: Next Thread 
GiverLol is not online. 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 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
16 Sep 2011 09:34 AM
It's not yours right?
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
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
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
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 is not online. 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 is not online. GiverLol
Joined: 20 Dec 2010
Total Posts: 810
16 Sep 2011 09:40 AM
from*
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
16 Sep 2011 09:40 AM
Umm, no problem.


-Like an __AWESOME__ boss
Report Abuse
GiverLol is not online. 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 is not online. GiverLol
Joined: 20 Dec 2010
Total Posts: 810
16 Sep 2011 10:17 AM
Bump.
Report Abuse
GiverLol is not online. GiverLol
Joined: 20 Dec 2010
Total Posts: 810
17 Sep 2011 01:23 AM
Bump.
Report Abuse
GiverLol is not online. GiverLol
Joined: 20 Dec 2010
Total Posts: 810
18 Sep 2011 04:16 AM
Bump.
Report Abuse
kingmod123 is not online. kingmod123
Joined: 16 May 2009
Total Posts: 699
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
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