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

How to change Brick Color with a script?

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?

3 comments

0

Are you attempting to input a number, and that number determines the color change?

0

What's inValue?

0

well i see no errors except that the "Dark Blue" should have a lower case "B" in the word "Blue"

1 answer

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

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