why wont this work? when i play it nothing happens.
01 | function OnPlayerJoin(player) |
02 |
03 | local leaderstats = Instance.new( "Folder" ,player) |
04 | leaderstats.Name = "leaderstats" |
05 |
06 | local points = Instance.new( "IntValue" ,player) |
07 | points.Name = "Points" |
08 |
09 |
10 | end |
11 |
12 | game.Players.PlayerAdded:Connect(OnPlayerJoin) |
Try this instead:
01 | function OnPlayerJoin(player) |
02 |
03 | local leaderstats = Instance.new( "Folder" ) |
04 | leaderstats.Name = "leaderstats" |
05 |
06 | local points = Instance.new( "IntValue" ) |
07 | points.Name = "Points" |
08 |
09 | leaderstats.Parent = player |
10 | points.Parent = leaderstats |
11 |
12 | end |
13 |
14 | game.Players.PlayerAdded:Connect(OnPlayerJoin) |
First, Points has to be in leadertstats, not the player. Second, it's better not to use the parent argument of Instance.new
the parent of "Points" is a player, when it should be the leaderstats
01 | function OnPlayerJoin(player) |
02 |
03 | local leaderstats = Instance.new( "Folder" ,player) |
04 | leaderstats.Name = "leaderstats" |
05 |
06 | local points = Instance.new( "IntValue" ,leaderstats) -- changed "player" to "leaderstats" |
07 | points.Name = "Points" |
08 |
09 |
10 | end |
11 |
12 | game.Players.PlayerAdded:Connect(OnPlayerJoin) |
01 | function OnPlayerJoin(player) |
02 |
03 | local leaderstats = Instance.new( "Folder" ,player) |
04 | leaderstats.Name = "leaderstats" |
05 |
06 | local points = Instance.new( "IntValue" ,leaderstats) --change here |
07 | points.Name = "Points" |
08 |
09 |
10 | end |
11 |
12 | game.Players.PlayerAdded:Connect(OnPlayerJoin) |
points parent needs to be the leaderstats folder