Hey there! I have a question.
I need to change the color of 904 parts named by the same name. I used the code but it only changes one part at a time and the rest remains the same. I will be glad to receive any help from you. Thank you!
All of these parts are called Snowpart and their location is game.Workspace.Map.Dirt.Grass.Snowpart
Here is my script:
local counter = 0
while counter < 905 do
wait(0)
game.Workspace.Map.Dirt.Grass.Snowpart.Material = Enum.Material.Snow
game.Workspace.Map.Dirt.Grass.Snowpart.BrickColor = BrickColor.new("Institutional white")
counter = counter + 1
end
for i, v in (workspace.Map.Dirt.Grass:GetChildren()) do -- This loops through every child stored in the 'Grass' Instance.
if v:IsA("BasePart") and v.Name == "Snowpart" then -- This checks if the children we're looping through are BaseParts and have the name 'Snowpart'
v.Material = Enum.Material.Snow
v.BrickColor = BrickColor.new("Institutional white")
end
end
Also, instead of using wait(), use task.wait() instead.
task.wait() is just better than wait(). There are no difference between both, but wait() can sometimes cause delays when it resumes the thread, so just always use task.wait()