Leaderboards and intvalues linked together?

Hello. I have 2 leaderboards in my game that are for 2 seperate IntValues, a Brick value and a Death value. Issue is that player randomly get a random value set on both of those IntValues and I’m unsure as to why. It also seems that the leaderboards get linked together like the values. What could be the issue?

LEADERBOARD SCREENSHOTS:


LEADERBOARD SCRIPT:

local DataStoreService = game:GetService("DataStoreService")
local BricksLeaderboard = DataStoreService:GetOrderedDataStore("SaveSystem")

local function updateLeaderboard()
	local success, errorMessage = pcall(function()
		local Data = BricksLeaderboard:GetSortedAsync(false, 10)
		local BricksPage = Data:GetCurrentPage()
		for Rank, data in ipairs(BricksPage) do
			local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
			local Name = userName
			local Bricks = data.value
			local isOnLeaderboard = false
			for i, v in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
				if v.Username.Text == Name then
					isOnLeaderboard = true
					break
				end
			end
			
			if Bricks > 0 and isOnLeaderboard == false then
				local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
				newLbFrame.Username.Text = Name
				newLbFrame.Bricks.Text = Bricks
				newLbFrame.Rank.Text = "#"..Rank
				newLbFrame.Position = UDim2.new(0,0, newLbFrame.Position.Y.Scale + (0.1 * #game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()), 0)
				newLbFrame.Parent = game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder
			end
		end
	end)
	
	if not success then
	end
end

while true do
	
	for _, player in pairs(game.Players:GetChildren()) do
		BricksLeaderboard:SetAsync(player.UserId, player.leaderstats.Bricks.Value)
	end
	
	for _, frame in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
		frame:Destroy()
	end
	
	updateLeaderboard()
	
	wait(120)
end

DATASTORE SCRIPT:

local datastore = game:GetService("DataStoreService")
local options = Instance.new("DataStoreOptions")
options.AllScopes = true
local ds = datastore:GetDataStore("SaveSystem")
local prefix = "Player_"
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local function saveFunction() 
	local playerData = ds:GetAsync(prefix .. tostring(game.Player.UserId)) 
	if playerData then
		game.Player.leaderstats.Bricks.Value = playerData[1] or 0
		game.Player.leaderstats.Deaths.Value = playerData[2] or 0
		game.Player.LotteryFolder.LotteryWins.Value = playerData[3] or 0
	else 
		ds:SetAsync(prefix .. tostring(game.Player.UserId), {
			game.Players.leaderstats.Bricks.Value,
			game.Players.leaderstats.Deaths.Value,
			game.Players.LotteryFolder.LotteryWins.Value
		})
	end
end


game.Players.PlayerAdded:Connect(function(player) -- once player joins, assign stats
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local BrickCount = Instance.new("Folder")
	BrickCount.Name = "BrickCount"
	BrickCount.Parent = player
	
	local LotteryFolder = Instance.new("Folder")
	LotteryFolder.Name = "LotteryFolder"
	LotteryFolder.Parent = player
	
	local BrickCountValue = Instance.new("IntValue")
	BrickCountValue.Name = "BrickCountValue"
	BrickCountValue.Parent = BrickCount
	
	local LotteryWins = Instance.new("IntValue")
	LotteryWins.Name = "LotteryWins"
	LotteryWins.Parent = LotteryFolder
	
	local bricks = Instance.new("IntValue")
	bricks.Name = "Bricks"
	bricks.Parent = leaderstats
	
	local deaths = Instance.new("IntValue")
	deaths.Name = "Deaths"
	deaths.Parent = leaderstats
	
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			deaths.Value = deaths.Value + 1
		end)
	end)
	
	local playerData = ds:GetAsync(prefix .. tostring(player.UserId)) -- THIS THING IS FOR SAVING STATS DONT TOUCH THIS LIKE EVER
	if playerData then
		bricks.Value = playerData[1] or 0
		deaths.Value = playerData[2] or 0
		LotteryWins.Value = playerData[3] or 0
	else 
		ds:SetAsync(prefix .. tostring(player.UserId), {
			bricks.Value,
			deaths.Value,
			LotteryWins.Value
		})
	end
end)

game.Players.PlayerRemoving:Connect(function(player) -- on player leaving, save stats
	ds:SetAsync(prefix .. tostring(player.UserId), {
		player.leaderstats.Bricks.Value,
		player.leaderstats.Deaths.Value,
		player.LotteryFolder.LotteryWins.Value
	})
end)

game:BindToClose(function() -- on server shutdown, save data
	if not RunService:IsStudio() and #Players:GetPlayers() > 1 then
		for _, player in ipairs(Players:GetPlayers()) do
			coroutine.wrap(saveFunction)(player)
		end
	end
end)

What I’m trying to achieve is for the Bricks and Deaths to save to the leaderboard seperately and for players to not be assigned stats out of nowhere.

do you have two different leaderboard scripts?

yes, i do. is it because of that? how would i go about having 2 seperate leaderboards?

just copy and paste the scripts

also you might want to give the scripts and leaderboards seperate names like: ScammerLeaderboard and EmployeeLeaderboard

thats what i’ve done, i have 1 for bricks 1 for deaths