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

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
