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

Surface GUI on mousebutton1down?

Asked by 9 years ago

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.

1 answer

Log in to vote
0
Answered by 9 years ago

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

0
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. DigitalProductionsHD 0 — 9y
0
ok i understand let me change the answer DragonSkyye 517 — 9y
Ad

Answer this question