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

If I want a frame to change backgroundcolor upon click of a textbutton, what would be the script?

Asked by 6 years ago

The GUI I'm trying to make is a GUI that shows online units (police, fire, EMS) and displays their status (available, busy, off-duty) through the color of a frame next to their name. I would like a script that changes the backgroundcolor of the frame when a player clicks one of three textbuttons that display different statuses. I don't have the script that will add the new GUI for every player who joins, but I don't care about that right now. I'm only testing with this one frame. I'm attempting to change the color of script.Parent.Parent.Units.Status1 script.Parent is a textbutton, Parent.Parent is a frame that holds the entirety of this GUI, Units has all the player's status, and Status1 is the frame whose color I need to change upon click of the textbutton.

1 answer

Log in to vote
0
Answered by 6 years ago

Here's something that might help:

status1 = script.Parent.Parent.Units.Status1

status1.MouseButton1Click:connect(function()
       status.BackgroundColor3 = Color3.new(0,170,0) -- This would change it to green.

       wait(0.2) --How much time until the color changes back

       status.BackgroundColor3 = Color3.new(0,0,0) -- Insert your color here.
end)
0
Thanks! It worked and really helped out. TurtlesMelons 0 — 6y
0
No problem :D XxJRushxX 22 — 6y
Ad

Answer this question