How to check if all players have a boolvalue true?

So I want to make a script that detect if all players are tagged and tps them into the lobby but I have some issues with my script, please help.

	for _, v in pairs(game.Players:GetChildren()) do
				if v.Character then
					if v.Character.Tagged.Value == true then
						game.ReplicatedStorage.Remotes.Round:FireAllClients("end", inter, roundtime)
						v.Character.Tagged.Value = false
						v.Character.HumanoidRootPart.Position = game.Workspace.Spawn.SP1.Position
					
					end
				end
			end

Thanks

Try this:

--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--//Loops
for i, player: Player in ipairs(Players:GetPlayers()) do
	if not player.Character or not player.Character.Tagged.Value then
		continue
	end
	
	ReplicatedStorage.Remotes.Round:FireAllClients("end", inter, roundtime)
	player.Character.Tagged.Value = false
	player.Character:MoveTo(workspace.Spawn.SP1.Position)
end
1 Like

If @Katrist 's script don’t work, try this:

local Tagged = { }
for _, v in pairs(game.Players:GetChildren()) do
	if v.Character then
		if v.Character.Tagged.Value then
			table.insert(Tagged, true)
		else
			table.insert(Tagged, false)
		end
	end
	wait()
end

if not table.find(Tagged, false) then
	-- do code
	for _, v in pairs(game.Players:GetPlayers()) do
	game.ReplicatedStorage.Remotes.Round:FireAllClients("end", inter, roundtime)
		v.Character.Tagged.Value = false
		v.Character.HumanoidRootPart.Position = game.Workspace.Spawn.SP1.Position
		wait()
	end
	Tagged = { }
end
1 Like

I tried this and it didn’t work cause when one player have the tagged value it tps him

I don’t really want to use tables for this

If you don’t want to use a table, you could use a bool value that gets set to false if theres a single untagged player.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local allTagged = true

for _, v in pairs(Players:GetPlayers()) do
	if not v.Character then continue end
	if not v.Character.Tagged.Value then allTagged = false end
end

if allTagged then
	ReplicatedStorage.Remotes.Round:FireAllClients("end", inter, roundtime)
	for _, v in pairs(Players:GetPlayers()) do
		v.Character.Tagged.Value = false
		v.Character.HumanoidRootPart.Position = workspace.Spawn.SP1.Position
	end
end
1 Like