Get all children help script [Script + video] thanks

  1. What do you want to achieve?
    Hello, as you can see on the video, I would like that when I touch the green part, all the parts that are blue turn red at the same time.

  2. What is the issue?

Here is the important part of the script that didn’t work well (see video)

workspace.Grandpa.JeuSol.ValidChoice.Touched:Connect(function(hit)
	if hit.Parent.Name == plr.Name then
		for _, child in ipairs(workspace.Grandpa.JeuSol.Lettres:GetChildren()) do
			if child:IsA('Part') then	
				child.CanTouch = false
				if child.Color == Color3.fromRGB(0, 225, 232) then
					child.Color = Color3.fromRGB(232, 0, 3)
				end
				wait(3)
				if child.Color == Color3.fromRGB(232, 0, 3) then
					child.Color = Color3.fromRGB(255, 184, 5)
				end
				Lettre.Value = 0
			end
		end
	end
end)

Thank you

Your issue probably boils down to the fact that you’re waiting 3 seconds after every part you check. All you’ll need to do is use a separate thread for each part you check, so they run simultaneously:

workspace.Grandpa.JeuSol.ValidChoice.Touched:Connect(function(hit)
	if hit.Parent.Name == plr.Name then
		for _, child in ipairs(workspace.Grandpa.JeuSol.Lettres:GetChildren()) do
			if child:IsA('Part') then
                spawn(function()	
					child.CanTouch = false
					if child.Color == Color3.fromRGB(0, 225, 232) then
						child.Color = Color3.fromRGB(232, 0, 3)
					end
					wait(3)
					if child.Color == Color3.fromRGB(232, 0, 3) then
						child.Color = Color3.fromRGB(255, 184, 5)
					end
					Lettre.Value = 0
                end)
			end
		end
	end
end)

Coroutines might be useful for future reference

1 Like

Thank you very much ! It work perfectly