why wont this work? when i play it nothing happens.
function OnPlayerJoin(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local points = Instance.new("IntValue",player) points.Name = "Points" end game.Players.PlayerAdded:Connect(OnPlayerJoin)
Try this instead:
function OnPlayerJoin(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" local points = Instance.new("IntValue") points.Name = "Points" leaderstats.Parent = player points.Parent = leaderstats end 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
function OnPlayerJoin(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local points = Instance.new("IntValue",leaderstats) -- changed "player" to "leaderstats" points.Name = "Points" end game.Players.PlayerAdded:Connect(OnPlayerJoin)
function OnPlayerJoin(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local points = Instance.new("IntValue",leaderstats) --change here points.Name = "Points" end game.Players.PlayerAdded:Connect(OnPlayerJoin)
points parent needs to be the leaderstats folder