Check if a for loop finished looping

Hello, so I was wondering how to wait until a for loop finished looping and than check if a player has a value inside of him but I have a problem the for loop has to loop through all of the players then check if a player have a value inside of him how can I do that?

Here is my code:

		for i, v in pairs(game.Players:GetPlayers()) do
			if v:FindFirstChild('ImposterValue') then
				game.ReplicatedStorage.Imposters:FireAllClients(v.Name)
				break
			else
				game.ReplicatedStorage.Crewmates:FireAllClients(v.Name)
			end
		end

Thank you!

After the loop is finished, it’s always after the entire scope of the loop: e.g. the closing end. Write the code right after the end.

4 Likes

As @anon81993163 said. The loop is fully finished after the closing end.

for i, v in pairs(game.Players:GetPlayers()) do
    --Code in here runs per player in the loop. One after another
end

--Code here runs after the loop has completed all players in the loop
6 Likes