New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
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
4 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 4 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 5386 — 4y
0
By the way, if this helped you please click the Accept Answer button under my name. 0xDEADC0DE 310 — 4y
Ad

Answer this question