Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would you skip during a loop without ending it?

for i,v in pairs(game.Players:GetPlayers()) do
	if v.Name == hit.Parent.Name then return end
	print(v.Name)
end

Hi this was just an example. I wanted it to make it so that the loop would print everyone's name except for the one person who touched the brick. When I use return end, it just ends the loop altogether. Is there a way so that I can skip that one player while letting the loop continue on?

1 comment

0

Conditional statements.

1 answer

Your script will nearly work.

It may turn out there is an easier way to do this, but:

for i,v in pairs(game.Players:GetPlayers()) do
    if v.Name ~= hit.Parent.Name then 
    	print(v.Name)
    end
end

It skips the one that it hits, but doesn't break the loop.

This discussion is preserved as it was. New answers, comments, and votes are closed.