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

How do I return the color of a part?

Asked by
Jexpler 63
6 years ago

Here is a portion of my script:

            for i,v in pairs(hit.Parent:GetChildren()) do
                if v.ClassName == "Part" then
                    local bc = Instance.new("StringValue")
                    bc.Parent = v
                    bc.Name = v.Name
                    bc.Value = v.BrickColor
                end
            end

It says that it expected a string, got brickcolor. How do I get the string value of a brickcolor?

1 answer

Log in to vote
2
Answered by
zor_os 70
6 years ago
Edited 6 years ago

Gotta use BrickColor.Name

for i,v in pairs(hit.Parent:GetChildren()) do
    if v.ClassName == "Part" then
        local bc = Instance.new("StringValue")
        bc.Parent = v
        bc.Name = v.Name
        bc.Value = v.BrickColor.Name -- Will give the name of the brickcolor in a string
    end
end
Ad

Answer this question