Bulk changing part colour from one colour to another

Hi, I am trying to make any part using the colour 40, 127, 71 change to 1,1,1 but for some reason I can’t get the code to work. Could anyone help me?

i, v in pairs(workspace:GetChildren()) do
     wait()
     if v.Color == Color3.new(40, 127, 71) then
          v.Color = Color3.new(1, 1, 1)
     end
end

When I run this code, I get the error i, v in pairs(workspacer:GetChildren()) do wait() if v.Color == Color3.new(40, 127, 71) then v.Color = Color3.new(1, 1, 1) end end:1: Expected '=' when parsing assignment, got 'in' - Studio

Hello @TheReal4Cedar123 I think this is a cicle so just include “For”

for i, v in pairs(workspace:GetChildren()) do
     wait()
     if v.Color == Color3.new(40, 127, 71) then
          v.Color = Color3.new(1, 1, 1)
     end
end
1 Like

I think you want Color3.fromRGB(40, 127, 71)
Also task.wait() instead of wait()

Thanks, I think the main issue is, it’s trying to check models and parts as well

Check if its ur wanted object by usimg obj:IsA()

What I see in the error is that you missed the “for” part of the loop, as InceptionStrange stated above.
And It’s not so good idea using wait() in a loop without any number.

I just did this, there are no errors but nothing is changing…?

for i, v in pairs(workspace:GetDescendants()) do
     wait()
     if v:IsA("MeshPart") and v.Material == Enum.Material.Grass and v.Color == Color3.fromRGB(40, 127, 71) then
          v.Color = Color3.fromRGB(1, 1, 1)
     end
end
for i, v in pairs(workspace:GetDescendants()) do
     wait()
     if v:IsA("MeshPart") and v.Color == Color3.fromRGB(40, 127, 71) then
          v.Color = Color3.fromRGB(1, 1, 1)
     end
end

Still nothing, it runs but nothing changes :frowning:

Is it a basepart ur object? If so, check if it is a BasePart.


for i, v in pairs(workspace:GetDescendants()) do
     if v:IsA("MeshPart") and v.Color == Color3.fromRGB(40, 127, 71) then
          v.Color = Color3.fromRGB(1, 1, 1)
     end
end

Alao tht wait is probably slowing it down. Try this code, wt i presume happened b4 was in each iteration it waited 1 second which means it will take longer to change color.

@TheReal4Cedar123 update me when u run this.

1 Like

I am wanting to change all the MeshParts, so they become white. Some of them are in the workspace and some are in models in the workspace