You should use a Click Detector, and a ServerScript inside of it assuming you want the change to be visible for everyone.
If you want it for just the player who clicked it, there will be a lot more to cover.
We then want to detect when a player has clicked it.
So we’d start with this:
----- Items -----
local clickDetector = script.Parent
local union = clickDetector.Parent
union.UsePartColor = true
We identify the items we’re going to need first, so the ClickDetector and then the Union.
To make sure the union will change color, we have to make the property “UsePartColor” true.
Then we have a factor “clicked”, this will tell us if it was the first click or not and switch back and fourth.
----- Factors -----
local clicked = false
Then we can create a function that will change this value (true/false) everytime it’s called.
When it switches, we’re going to see what the value is (true/false) then change the union accordingly.
----- Functions -----
local function onClick()
clicked = not clicked
if clicked then
union.Material = Enum.Material.Neon
union.BrickColor = BrickColor.new("Institutional White")
else
union.Material = Enum.Material.SmoothPlastic
union.BrickColor = BrickColor.new("Really black")
end
end
Then we connect the function to the MouseClick event.
----- Code -----
clickDetector.MouseClick:connect(onClick)
EDIT:
The final code would look like this
----- Items -----
local clickDetector = script.Parent
local union = clickDetector.Parent
union.UsePartColor = true
----- Factors -----
local clicked = false
----- Functions -----
local function onClick()
clicked = not clicked
if clicked then
union.Material = Enum.Material.Neon
union.BrickColor = BrickColor.new("Institutional White")
else
union.Material = Enum.Material.SmoothPlastic
union.BrickColor = BrickColor.new("Really black")
end
end
----- Code -----
clickDetector.MouseClick:connect(onClick)
----------------------- End of Edit
I’m aware similar code was posted, but I wanted to give more insight on what the code was doing that way you’re able to understand and hopefully learn 