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

Trying to change all the parts color but isn't responded to the "v.Material == "Grass" line?

Heres the script, it's responding to print the part's name but couldn't find the part's material.

for i,v in pairs(game.Workspace:GetChildren()) do
	if v.Name  == "P1" and v:IsA("WedgePart") then
		print(v.Name)
		if v.Material == "Grass" then		-- Not working here
			v.BrickColor = BrickColor.new("Medium green")
		end
		
	end
end

1 answer

✓ Accepted answer

use this:

if v.Material == Enum.Material.Grass then

2 comments

1

To explain, Enums internally are Integers, not Strings. Enum.Material.Grass == 1280, and 1280 ~= "Grass"

0

By the way, if this helped you please click the Accept Answer button under my name.

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