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

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

	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:getStat(player, stat)
	local leaderstats = player:FindFirstChild("leaderstats")
	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

	for i, stat in pairs(leaderstats:GetChildren()) do
		LeaderboardManager:resetState(player, stat)
	end
end

return LeaderboardManager
