Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this leaderboard work?

game.Players.PlayerAdded:connect(function(player)
	local leaderstats = Instance.new("leaderstat",player)
	leaderstats.Name = "leaderstats"
	
	local points = Instance.new('IntValue',leaderstats)
	points.Name = "Points" --Name of stat
	points.Value = "0"

end)

2 answers

✓ Accepted answer

There :)

--Made by GuardainDev
function Entered(player)
	wait()

	if player:findFirstChild("leaderstats") ~= nil then
		player.leaderstats:remove()
	end

	stats = Instance.new("IntValue")
	stats.Parent = player
	stats.Name = "leaderstats"

	money = Instance.new("IntValue")
	money.Parent = stats
	money.Name = "Points"
	money.Value = 0

end

game.Players.PlayerAdded:connect(Entered)

c = game.Players:GetChildren()
for i=1, #c do
	Entered(c[i])
end

Try making leaderstats and points not local. Also, slightly change your code to this:

--Make sure your script is a local script
Player = game.Player.LocalPlayer
game.Players.PlayerAdded:connect(function(player)
    leaderstats = Instance.new("leaderstat",Player) --Player now has a variable set, so that should work
    leaderstats.Name = "leaderstats"

    points = Instance.new('IntValue',leaderstats)
    points.Name = "Points" --Name of stat
    points.Value = "0"

end)

If it doesn't work let me know. I'm no leaderstats expert after all.

This discussion is preserved as it was. New answers, comments, and votes are closed.