Change the Background Color of a GUI

I’m trying to make a script that if you click a TextButton the color of the gui changes. There’s nothing in the output. I searched the dev forum and found this.Here is the script I made:

local speedgui = script.Parent.Parent
script.Parent.FocusLost:Connect(function(click)
	if click then
		
		speedgui.BackgroundColor3 = Color3.fromRGB(139,0,0)
		
		

	end
end)

I’m trying to make it so all the guis change to the color you selected. Here is what it looks like in StarterGui.
Screen Shot 2020-08-22 at 4.48.29 PM
If you see an error in the script please let me know, thanks.

7 Likes

All of them, for the start I just want to change one. For now I want to change the color of the frame “change”. I tried changing it but for some reason it wouldn’t change the color.

2 Likes

Got it. Considering your layout, this script should solve the problem:

local speedgui = script.Parent.Parent

script.Parent.MouseButton1Click:Connect(function()
    speedgui.BackgroundColor3 = Color3.fromRGB(139,0,0)
end)

If it doesn’t work, try using print statements.

15 Likes

Screen Shot 2020-08-22 at 6.01.33 PM
You need a TextBox, not a TextButton.

Unless you want it to be clicked, then use @DecodedMint’s script.


Also,

Making one thing change color doesn’t make it’s descendants change color.

3 Likes