Leaderstats Help

Having trouble wit a data store + leader stats script. New to this, what am I doing wrong?

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Stats")

game.Players.PlayerAdded:Connect(function(Player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = Player
	local stats = Instance.new("StringValue")
	stats.Value = DataStore:GetAsync(Player.UserId) or 0
	stats.Name = "Points"
	stats.Parent = leaderstats
end)

game.Players.PlayerRemoving:Connect(function(Player)
	DataStore:SetAsync(Player.UserId, Player.leaderstats.stats.Value)
end)



print("Community Leaderboard script loaded")


function onPlayerEntered(newPlayer)

	local stats = Instance.new("IntValue")
	stats.Name = "Points"

	local mins = Instance.new("IntValue")
	mins.Name = "Points"
	mins.Value = 0


	mins.Parent = stats
	
	stats.Parent = newPlayer

	while true do
		wait(60)
		mins.Value = mins.Value + 10
	end
end



game.Players.ChildAdded:connect(onPlayerEntered)

A few things are wrong.

To begin with, you are already creating the leaderstats on PlayerAdded, so I do not know why you are also firing the onPlayerEntered() function. That function should not even exist at all.

You are creating a StringValue, but you are trying to give it a value of 0, which is an integer, not a string.

You can insert the while wait(60) do loop after stats.Parent = leaderstats.

Thank you, it works perfectly now!