How to fix strange but with script?

  1. What do you want to achieve? I’m making a game where a color displays and you have to get to that color and not any other colors and after like 5 seconds all the other colors disappear EXCEPT that color.

  2. What is the issue? For some reason its just removing a lot of random blocks instead of picking one and removing the rest.

Example of it (See in output how it’s removing like A LOT of different colors instead of just 1

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
function findBricks(ColorParts)
	for k,v in pairs(ColorParts:GetDescendants()) do
		local ChosenColor = BrickColors[math.random(1, #BrickColors)]
		if v:IsA("BasePart") and v.BrickColor ~= BrickColor.new(ChosenColor) then
			v.Transparency = 1
			v.CanCollide = false
			print(ChosenColor)
		end
	end
end

This is happening cause your script is removing all the parts which are not the chosen color

1 Like

Put your chosen color variable above the for loop

1 Like