Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by
Adryin 120
10 years ago

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

Log in to vote
2
Answered by 10 years ago

use this:

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

1
To explain, Enums internally are Integers, not Strings. Enum.Material.Grass == 1280, and 1280 ~= "Grass" adark 5487 — 10y
0
By the way, if this helped you please click the Accept Answer button under my name. 0xDEADC0DE 310 — 10y
Ad

Answer this question