This is my script:
1 | game.Players.PlayerAdded:connect( function (player) |
2 | local leaderstats = Instance.new( "Model" , player) |
3 | leaderstats.Name = "leaderstats" |
4 | local money = Instance.new( "IntValue" , leaderstats) |
5 | money.Name = Money |
6 | money.Value = 100 |
7 | 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 | game.Players.PlayerAdded:connect( function (player) |
2 | player:WaitForDataReady() -- Always do this in Data Persistence. |
3 | local leaderstats = Instance.new( "IntValue" , player) -- I don't know if models work but I use IntValues for this. |
4 | leaderstats.Name = "leaderstats" |
5 | local money = Instance.new( "IntValue" , leaderstats) |
6 | money.Name = Money |
7 | money.Value = money.Value + 100 |
8 | end ) |
EDIT: Added my leaderboard.
01 | game.Players.PlayerAdded:connect( function (Player) |
02 |
03 |
04 |
05 | a = Instance.new( "IntValue" ) |
06 | a.Name = "leaderstats" |
07 | b = Instance.new( "IntValue" ) |
08 | b.Name = "Points" |
09 |
10 | a.Parent = Player |
11 | b.Parent = a |
12 |
13 |
14 | Player:WaitForDataReady() |
15 | if Player:LoadNumber( "Points" ) ~ = 0 then |
16 | Player.leaderstats.Points.Value = Player:LoadNumber( "Points" ) |
17 |
18 |
19 | end |
20 | end ) |