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

How to change Brick Color with a script?

Asked by 7 years ago
Edited by OldPalHappy 7 years ago
local Parent = script.Parent

local ChangeColor = Parent.BrickColor

local intValue = game.Workspace.Value

if intValue == 1 then 
    ChangeColor = BrickColor.new("Gold")
    if intValue == 0 then 
        ChangeColor = BrickColor.new("Dark Blue")   
    end
end

For some reason this won't work? And it has no output error?

0
Are you attempting to input a number, and that number determines the color change? waifuSZN 123 — 7y
0
What's inValue? AstrealDev 728 — 7y
0
well i see no errors except that the "Dark Blue" should have a lower case "B" in the word "Blue" wookey12 174 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

You need to do it like this, when you want to change a property of an object, never set a variable to local x = object.someproperty, instead use local x = object Then when you need to change that value, use x.Property = whatever.

local ChangeColor = script.Parent;

local intValue = game.Workspace.Value

if intValue == 1 then 
    ChangeColor.BrickColor= BrickColor.new("Gold")
    if intValue == 0 then 
        ChangeColor.BrickColor = BrickColor.new("Dark Blue")   
    end
end

Ad

Answer this question