You have a few problems. First of all, their is no reason to do wait(0), this will not do anything for you so you would need to do wait()
.
I guess the reason of while true do is so you can continuously have them change? that would seem excessive, if the colors will not change again, then don't run it through an infinite loop.
Also, you're not checking the color correctly on line 5, you still need to use .new, it will NOT change the part because of this, you're using ==
not =
. You will probably have things in your Workspace that are not Parts and will cause an error because they cannot change their color, to fix this we use IsA("ClassName")
, just so you know, some things you may want to change could have a different name such as UnionOperation! Edit this for your own need. Now with the information I provided, here is a script to run once when the game is started, no infinite loop:
1 | local parts = Workspace:GetChildren() |
2 | for _, child in pairs (parts) do |
3 | if child.BrickColor = = BrickColor.new( "Really black" ) and child:IsA( "Part" ) then |
4 | child.BrickColor = BrickColor.new( "Really red" ) |
Now if you want it to do this continuously , then here's the script bellow.
1 | local parts = workspace:GetChildren() |
4 | for _, child in pairs (parts) do |
5 | if child.BrickColor = = BrickColor.new( "Really black" ) and child:IsA( "Part" ) then |
6 | child.BrickColor = BrickColor.new( "Really red" ) |