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

Clicking a button to change the color of another brick?

I am attempting to change the Color3 of multiple SelectionBoxes to the same color by clicking a single button. I changed the name of the SelectionBox to "sb." What I put inside of the part I want them to click in order to change the color is the following:

function onClick(clicked) game.Workspace.sb.Color3 = Color3.new("Institutional White") -- Name of the Selection box was changed to "sb". script.Parent.MouseButton1Down:connect(clicked) end

I tried a few other things but none of them seemed to work.

(I am a very new at scripting)

2 comments

0

Please use a code black :)

0

block*

1 answer

Color3 is different from BrickColor, You are trying to use a BrickColor for a Color3, if you are trying to change the color of the Color3, in this case, White, do this instead.

You had the 'end' in the wrong spot, you put the connect after the end, in this case.

You are also trying to use script.Parent, if this is not going into a Part, You want to connect it to a part by making a new instance of a part.

local Part = Instance.new("Part", workspace)
local Click = Instance.new("ClickDetector", Part)
local SelectionBox = Instance.new("SelectionBox", Part)
SelectionBox.Adornee = Part

function OnClick(Click)
SelectionBox.Color3 = Color3.new(255,255,255)
end

Click.MouseClick:connect(OnClick)

From what I can see, you didn't have anything setup correctly, you were trying to use MouseButton which is used in GUIs

This should work, I hope I helped ;)

If I did not understand you correctly, just respond on this and I will help you again!

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