Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Whats wrong with this LeaderBoard?

Asked by 10 years ago

This is my script:

1game.Players.PlayerAdded:connect(function(player)
2local leaderstats = Instance.new("Model", player)
3leaderstats.Name = "leaderstats"
4local money = Instance.new("IntValue", leaderstats)
5money.Name = Money
6money.Value = 100
7end)

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

Log in to vote
1
Answered by 10 years ago
1game.Players.PlayerAdded:connect(function(player)
2player:WaitForDataReady() -- Always do this in Data Persistence.
3local leaderstats = Instance.new("IntValue", player) -- I don't know if models work but I use IntValues for this.
4leaderstats.Name = "leaderstats"
5local money = Instance.new("IntValue", leaderstats)
6money.Name = Money
7money.Value = money.Value +100
8end)

EDIT: Added my leaderboard.

01game.Players.PlayerAdded:connect(function(Player)
02 
03 
04 
05a = Instance.new("IntValue")
06a.Name = "leaderstats"
07b = Instance.new("IntValue")
08b.Name = "Points"
09 
10a.Parent = Player
11b.Parent = a
12 
13 
14Player:WaitForDataReady()
15if Player:LoadNumber("Points") ~= 0 then
16Player.leaderstats.Points.Value = Player:LoadNumber("Points")
17 
18 
19end
20end)
0
Also "Normal Play Mode" has an output. Press F9 when in that mode. legoguy939 418 — 10y
0
Thanks! I can use a leaderboard for my game now! User#5565 45 — 10y
0
No problem dude. legoguy939 418 — 10y
View all comments (8 more)
0
I explained it in my code. So I only needed to post the code. legoguy939 418 — 10y
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... User#5565 45 — 10y
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. legoguy939 418 — 10y
0
I'm gonna keep trying, but when I used your script, it didn't even come up with a leaderbaord... :( User#5565 45 — 10y
0
Where are you putting this? Workspace is where mine is. legoguy939 418 — 10y
0
Yeah... User#5565 45 — 10y
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. legoguy939 418 — 10y
1
THANK YOU! That one works! Thank you so much! User#5565 45 — 10y
Ad

Answer this question