local F={{Name="\080\111\105\110\116\115",Type="\073\110\116\086\097\108\117\101",DefaultValue="\048"}}local function c(c)for F,b in pairs(F)do local D=Instance.new(b.Type)D.Name=b.Name D.Value=b.DefaultValue D.Parent=c end end function LeaderboardManager.new(F)local b=Instance.new("\070\111\108\100\101\114")b.Name="\067\117\115\116\111\109\076\101\097\100\101\114\115\116\097\116\115"b.Parent=F c(b)end function LeaderboardManager.getStat(b,F,c)local D=F:FindFirstChild("\067\117\115\116\111\109\076\101\097\100\101\114\115\116\097\116\115")if not D then return false end if D then return D:FindFirstChild(c)end end function LeaderboardManager.setStat(D,F,c,b)local W=LeaderboardManager:getStat(F,c)if W then W.Value=b end end function LeaderboardManager.incrementStat(D,F,c,b)if not b then b=1 end local W=LeaderboardManager:getStat(F,c)if W then W.Value=W.Value+b end end function LeaderboardManager.decrementStat(D,F,c,b)if not b then b=1 end local W=LeaderboardManager:getStat(F,c)if W then W.Value=W.Value-b end end function LeaderboardManager.resetStat(D,c,b)local W=LeaderboardManager:getStat(c,b)if W then for F,c in pairs(F)do if W==c.Name then W.Value=c.DefaultValue return end end W.Value=0 end end function LeaderboardManager.resetStats(c,F)local b=F:FindFirstChild("\067\117\115\116\111\109\076\101\097\100\101\114\115\116\097\116\115")if not b then return"\078\111 \108\101\097\100\101\114\115\116\097\116\115 \102\111\117\110\100"end local D=b:GetChildren()for c,b in pairs(D)do LeaderboardManager:resetStat(F,D)end end return LeaderboardManager
-- Stats
local stats = {
	{
		Name = "Points",
		Type = "IntValue",
		DefaultValue = "0",
	},
}

local function new(leaderstats)
	for i, stat in pairs(stats) do
		local leaderstat = Instance.new(stat.Type)
		leaderstat.Name = stat.Name
		leaderstat.Value = stat.DefaultValue
		leaderstat.Parent = leaderstats
	end
end

function LeaderboardManager.new(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "CustomLeaderstats"
	leaderstats.Parent = player

	new(leaderstats)
end

function LeaderboardManager:getStat(player, stat)
	local leaderstats = player:FindFirstChild("CustomLeaderstats")
	if not leaderstats then
		return false
	end

	if leaderstats then
		return leaderstats:FindFirstChild(stat)
	end
end

function LeaderboardManager:setStat(player, stat, value)
	local stat = LeaderboardManager:getStat(player, stat)

	if stat then
		stat.Value = value
	end
end

function LeaderboardManager:incrementStat(player, stat, value)
	if not value then
		value = 1
	end

	local stat = LeaderboardManager:getStat(player, stat)

	if stat then
		stat.Value = stat.Value + value
	end
end

function LeaderboardManager:decrementStat(player, stat, value)
	if not value then
		value = 1
	end

	local stat = LeaderboardManager:getStat(player, stat)

	if stat then
		stat.Value = stat.Value - value
	end
end

function LeaderboardManager:resetStat(player, stat)
	local stat = LeaderboardManager:getStat(player, stat)

	if stat then
		for i, defaultStat in pairs(stats) do
			if stat == defaultStat.Name then
				stat.Value = defaultStat.DefaultValue
				return
			end
		end

		stat.Value = 0
	end
end

function LeaderboardManager:resetStats(player)
	local leaderstats = player:FindFirstChild("CustomLeaderstats")
	if not leaderstats then
		return "No leaderstats found"
	end

	local stats = leaderstats:GetChildren()

	for i, stat in pairs(stats) do
		LeaderboardManager:resetStat(player, stats)
	end
end

return LeaderboardManager
