Why doesn't a part of my script fire all the time?

Heres the script, mind you that this is part of the script, the rest isn’t necessary.

local function selectPlayer()
	
	local Players = game.Players
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local remoteEvent = ReplicatedStorage:WaitForChild("gameupdate")
	local status = 'waiting'
	remoteEvent:FireAllClients(status)
	wait(10)
	game.ServerScriptService.isround.Value = true
	local allPlayers = Players:GetPlayers() -- Getting all the players
	local selectedPlayer = allPlayers[math.random(1, #allPlayers)]
	for _, Player in ipairs(allPlayers) do
		print(selectedPlayer.Name)
		if Player == selectedPlayer then
			print("1")
			local status = 'tagged'
			print("2")
			remoteEvent:FireClient(selectedPlayer, status)
			print("3")
			game.Players[selectedPlayer.Name].istagged.Value = true
			print("4")
			game.Workspace[selectedPlayer.Name].UpperTorso.BillboardGui.Enabled = true
			print("5")
		else
			print("something aint right")
			local status = 'nottagged'
			remoteEvent:FireClient(Player, status)
			game.Players[Player.Name].istagged.Value = false
		end
		for i = 60, 1, -1 do
			local status = i
			remoteEvent:FireAllClients(i)
			wait(1)
		end
		game.ServerScriptService.isround.Value = false
		local status = 'end'
		remoteEvent:FireAllClients(status)
		
		
		local children = game.Players:GetChildren()
		for i = 1, #children do
			if children[i].istagged.Value == true then
				print(children.Name)
			end
		end
		
	end
end

The function is firing, because sometimes it selects a player, and other times it just skips over that part. Same with the non selected player. No output errors, it also prints the name of the selected player, but it doesn’t seem to matter.

Lets say player a is the selected player, while player b isn’t. sometimes player a, while the name prints, the billboardgui inside of the torso doesn’t show up, and the tagged value inside of game.Players.playera doesn’t show up true. And sometimes, the player b playergui doesn’t update with the game status.

replaced this script with an old one I found:

local function selectPlayer()
	
	local Players = game.Players
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local remoteEvent = ReplicatedStorage:WaitForChild("gameupdate")
	local status = 'waiting'
	remoteEvent:FireAllClients(status)
	wait(10)
	game.ServerScriptService.isround.Value = true
	
	local PlayersTable = Players:GetPlayers()
	local RandomPlayer = PlayersTable[math.random(#PlayersTable)]
	for i = 1, #PlayersTable do
		local Player = PlayersTable[i]
		if Player == RandomPlayer then
			local status = 'tagged'
			remoteEvent:FireClient(RandomPlayer, status)
			game.Players[RandomPlayer.Name].istagged.Value = true
			game.Workspace[RandomPlayer.Name].UpperTorso.BillboardGui.Enabled = true
		else
			local status = 'nottagged'
			remoteEvent:FireClient(Player, status)
			game.Players[Player.Name].istagged.Value = false
		end
	end
		
		for count = 5, 0, -1 do
			local status = 'time'
		remoteEvent:FireAllClients(status, count)
		print(count)
			wait(1)
		end
		game.ServerScriptService.isround.Value = false
		local status = 'end'
		remoteEvent:FireAllClients(status)
		
		
		local children = game.Players:GetChildren()
		for i = 1, #children do
			if children[i].istagged.Value == true then
				print(children.Name)
			end
		end
	end

This is the important bit:

local PlayersTable = Players:GetPlayers()
	local RandomPlayer = PlayersTable[math.random(#PlayersTable)]
	for i = 1, #PlayersTable do
		local Player = PlayersTable[i]
		if Player == RandomPlayer then
			local status = 'tagged'
			remoteEvent:FireClient(RandomPlayer, status)
			game.Players[RandomPlayer.Name].istagged.Value = true
			game.Workspace[RandomPlayer.Name].UpperTorso.BillboardGui.Enabled = true
		else
			local status = 'nottagged'
			remoteEvent:FireClient(Player, status)
			game.Players[Player.Name].istagged.Value = false
		end
	end