How would I reward a badge if a player got x number of points in leaderboard?

I would like to reward badges for when a player reaches 1, 10, 100, 1,000, and 10,000 survival(s). How would I do that in this code?

local Players = game:GetService("Players")
local playerTable = {}
local function onPlayerDied(player)
	print(player.Name .. " has died")
	if playerTable[player.Name] then
		playerTable[player.Name]["isAlive"] = false
	end
end

local DataStoreService = game:GetService("DataStoreService")
local playerDataStore = DataStoreService:GetDataStore("PlayerData")
local function onPlayerAdded(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local survivals = Instance.new("IntValue")
	survivals.Name = "Survivals"
	survivals.Value = 0
	survivals.Parent = leaderstats

	-- Load player's data from the data store
	local userId = player.UserId

	-- Attempt to retrieve the player's survival data from the data store
	local success, data = pcall(function()
	return playerDataStore:GetAsync(userId)
	end)

	if success then
		if type(data) == "table" and data.survivalStats then
			survivals.Value = data.survivalStats
		else
			survivals.Value = 0
		end
	else
		warn("Failed to retrieve survival data for player " .. player.Name)
	end
	end
game.Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerDied)
Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:FindFirstChild("Humanoid").Died:Connect(function()
			onPlayerDied(plr)
		end)
	end)
end)
local function playerRemoving(plr)
	local success, data = pcall(function()
		local survivalStats = {survivalStats = plr.leaderstats.Survivals.Value}
		return playerDataStore:SetAsync(plr.UserId, survivalStats)
	end)
	if not success then warn("Error while saving data: "..data) end
end
function startNewRound()
	playerTable = {}
	print("Starting")
	for _, player in ipairs(Players:GetPlayers()) do
		playerTable[player.Name] = {
			["isAlive"] = true
		}
	end
end
function endRound()
	print("Ended")
	for _, player in ipairs(Players:GetPlayers()) do
		if playerTable[player.Name] and playerTable[player.Name]["isAlive"] then
			local leaderstats = player:FindFirstChild("leaderstats")
			if leaderstats then
				local survivals = leaderstats:FindFirstChild("Survivals")
				if survivals then
					survivals.Value = survivals.Value + 1
					print("Added a survival")
				end
			end
		end
	end
end


game.Players.PlayerRemoving:Connect(playerRemoving)


First off all you need to create a badge in the creator hub then get his asset id, use BadgeService:AwardBadge(userId, badgeId) on the sucess result from pcall if the player has some survival requirements.

You can learn more about badges here: