Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Changing color + material script?

p = workspace:GetChildren() 
for i=1, #p do 
if p[i].className == "Part" or "Wedge" then
if p[i].BrickColor == BrickColor.new("White") and p[i].Material == "Slate" then
p[i].BrickColor = BrickColor.new("Grime")
p[i].Material = "Grass"
		end
	end
end

The problem I'm running into is that there are models in the workspace, and BrickColor & Material are not characteristics of Models.

So if you don't understand, I need this script to change any part or wedge that is colored white, and has the material called Slate.. except it also attempts to change the models in the workspace.

1 comment

0

Your error was or "wedge", you needed to put p[i].className == "Wedge" although :IsA("BasePart") is a better alternative.

1 answer

✓ Accepted answer
for _,v in pairs (workspace:GetChildren())
	if v:IsA("BasePart") then
		if v.BrickColor == BrickColor.new("White") and v.Material == "Slate" then
			v.BrickColor = BrickColor.new("Grime")
			v.Material = "Grass"
		end
	end
end

"Your error was or "wedge", you needed to put p[i].className == "Wedge" although :IsA("BasePart") is a better alternative." -DevSean

And I changed the for loop to a generic one just because I prefer it over numeric when working with objects.

2 comments

0

Don't just past code, explain what was wrong and why your code works.

0

didn't have time to do that at the time.

This discussion is preserved as it was. New answers, comments, and votes are closed.