Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Whats wrong with this LeaderBoard?

This is my script:

game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats)
money.Name = Money
money.Value = 100
end)

I got this from the wiki while trying to learn how to make a LeaderBoard. When I play the game, the it says:

SynphonyKnight 0

Not only do I have 0 (not 100, as I set it to), but it says I have 0 "Value", not Money. I guess the wiki is outdated, so will someone please tell me what's wrong with it.

I can't check the output because when I click Play Solo a message pops up saying "Error Loading Starter Script" and Roblox Studio crashes. The only way I can test is by closing and saving the studio, then clicking play, and since I'm normal playing it doesn't have the output.

Please help!!!

1 answer

✓ Accepted answer
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady() -- Always do this in Data Persistence.
local leaderstats = Instance.new("IntValue", player) -- I don't know if models work but I use IntValues for this.
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats)
money.Name = Money
money.Value = money.Value +100
end)

EDIT: Added my leaderboard.

game.Players.PlayerAdded:connect(function(Player)



a = Instance.new("IntValue")
a.Name = "leaderstats"
b = Instance.new("IntValue")
b.Name = "Points"

a.Parent = Player
b.Parent = a


Player:WaitForDataReady()
if Player:LoadNumber("Points") ~= 0 then
Player.leaderstats.Points.Value = Player:LoadNumber("Points")
	

end
end)


12 comments

0

Also "Normal Play Mode" has an output. Press F9 when in that mode.

0

Thanks! I can use a leaderboard for my game now!

0

No problem dude.

0

I explained it in my code. So I only needed to post the code.

0

I tried it... and it doesn't seem to work. It still says I have 0 Value. For some reason local variable money isn't working correctly...

0

Put the script in workspace. This should work, 100% positive. I'll give you my leaderboard that I made in 2013 and you can take a look at it.

0

I'm gonna keep trying, but when I used your script, it didn't even come up with a leaderbaord... :(

0

Where are you putting this? Workspace is where mine is.

0

Yeah...

1

Try my edited version and mess around with it. I didn't know I had the b's parent set to something that was NIL.

1

THANK YOU! That one works! Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.