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

Clicking a button to change the color of another brick?

Asked by 7 years ago

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)

0
Please use a code black :) Async_io 908 — 7y
0
block* Async_io 908 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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!

Ad

Answer this question