I'm looking for help on, if I were to click a button, the BackgroundColor3 would change to the color put in the script. Say, the original background color is (0, 0, 0), If I wanted it to change to (255, 0, 0) and then (255, 255, 255), what would be a script to do this? Please remember I'm just starting on Surface GUI's.
COMMUNITY QUESTION
Surface GUI on mousebutton1down?
1 answer
Heres some help
In a server-script
local SG = script.Parent -- make sure the script is inside the surface gui
local Frame = SG.Frame -- get the frame
local Button = Frame.Button -- get the button which is inside frame
local Brick = SG.Parent -- make sure the SurfaceGui is inside the brick/part
function RGB(r,g,b) -- red, green, blue
return Color3.new(r/255,g/255,b/255) -- return the colors
end
Button.MouseButton1Click:connect(function(Clicked!) -- using an anonymous function
if Button.BackgroundColor3 == RGB(255,0,0) then -- check if BackgroundColor3 equals 255,0,0
Button.BackgroundColor3 = RGB(255,255,255) -- change color
elseif Button.BackgroundColor3 == RGB(255,255,255) then
Button.BackgroundColor3 = RGB(255,0,0)
end
end)
if this helped please upvote my answer
also remember that screengui's act like regular guis just a bit different
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Uh... Let me clarify what I tried saying.. I now notice it can be worded differently. So, the button has no surface GUI and is just a button used to make a brick (LED1) change color of it's surface GUI backgroundcolor3. xD Sorry for the misunderstanding.
ok i understand let me change the answer