01 | print ( "Cash Leaderboard Loaded" ) |
02 |
03 |
04 | function onPlayerEntered(newPlayer) |
05 |
06 | local stats = Instance.new( "IntValue" ) |
07 | stats.Name = "leaderstats" |
08 |
09 | local cash = Instance.new( "IntValue" ) |
10 | cash.Name = "Money" --name of currency (e.g. cash, money, resources, bucks, etc.) |
11 | cash.Value = 1000 --starting money. |
12 |
13 | cash.Parent = stats |
14 | stats.Parent = newPlayer |
15 | end |
It won't give me money nor I can't see it on the leaderboard. Please help.
Hey,
You've got two unnecessary "end"s on line 20 and 21.
You usually have an end after an if, an function and so on.
I also changed ChildAdded to PlayerAdded, that is better and then it wont break if something else is inserted into Players.
Here is the code with the problem solved:
01 | print ( "Cash Leaderboard Loaded" ) |
02 |
03 |
04 | function onPlayerEntered(newPlayer) |
05 |
06 | local stats = Instance.new( "IntValue" ) |
07 | stats.Name = "leaderstats" |
08 |
09 | local cash = Instance.new( "IntValue" ) |
10 | cash.Name = "Money" --name of currency (e.g. cash, money, resources, bucks, etc.) |
11 | cash.Value = 1000 --starting money. |
12 |
13 | cash.Parent = stats |
14 | stats.Parent = newPlayer |
15 | end |
The first problem is that when you are making a leaderboard you first have to make a model and name it 'leaderstats'.
This will work, I removed the first function because I didn't see the purpose of it
01 | print ( "Cash Leaderboard Loaded" ) |
02 |
03 | game.Players.PlayerAdded:connect( function (p) |
04 | local stats = Instance.new( "Model" ) |
05 | stats.Parent = p |
06 | stats.Name = "leaderstats" |
07 | local money = Instance.new( "IntValue" ) |
08 | money.Parent = stats |
09 | money.Name = "Cash" |
10 | money.Value = 100 |
11 | while true do |
12 | wait( 5 ) |
13 | money.Value = money.Value + 10 |
14 | end |
15 | end ) |