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:

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

Log in to vote
1
Answered by 10 years ago
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)


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