Formatting:
Firstly, let's put your code into a code block using the little Lua button when making your post.
3 | game.Players.PlayerAdded:connect( function (player) local leaderstats = Instance.new( "Model" ) leaderstats.Name = "Jo3thebombsStats" leaderstats.Parent = player local money = Instance.new( "IntValue" ) money.Name = "Money" money.Value = 0 money.Parent = leaderstats local fish = Instance.new( "IntValue" ) fish.name = "Fish" fish.Value = 0 fish.Parent = leaderstats end ) |
Much better, now we can see the syntax you're using! But, the code is messy and unreadable. Let's add line breaks to it and make some whitespace to make it more visible.
03 | game.Players.PlayerAdded:connect( function (player) |
04 | local leaderstats = Instance.new( "Model" ) |
05 | leaderstats.Name = "Jo3thebombsStats" |
06 | leaderstats.Parent = player |
07 | local money = Instance.new( "IntValue" ) |
10 | money.Parent = leaderstats |
11 | local fish = Instance.new( "IntValue" ) |
14 | fish.Parent = leaderstats |
Now this is more like it! You, I and many others can now see that the code is formatted correctly and now we can begin to find out what the problem is.
The problem:
So, the problem is that you're not naming your leaderstats model "leaderstats". ROBLOX requires you to make an object with the name of leaderstats to add items to the leaderboard. So, we can now change this:
03 | game.Players.PlayerAdded:connect( function (player) |
04 | local leaderstats = Instance.new( "Model" ) |
05 | leaderstats.Name = "leaderstats" |
06 | leaderstats.Parent = player |
07 | local money = Instance.new( "IntValue" ) |
10 | money.Parent = leaderstats |
11 | local fish = Instance.new( "IntValue" ) |
14 | fish.Parent = leaderstats |
Improvements to the code itself:
Now that should work. But, we can make this code more efficient. There is a second argument to the Instance.new method which sets the parent for you.
This gets rid of one less line from each time you make a new instance and shortens your code, which is very helpful when people are trying to read your code as they have less to read.
Final code:
03 | game.Players.PlayerAdded:connect( function (player) |
04 | local leaderstats = Instance.new( "Model" ,player) |
05 | leaderstats.Name = "leaderstats" |
06 | local money = Instance.new( "IntValue" ,leaderstats) |
09 | local fish = Instance.new( "IntValue" ,leaderstats) |
I hope my answer helped you. If it did, be sure to accept it.