Mousebutton1click:connect(function() to change color of ui help!

hello. im trying to make a script that when the player press “apply” it turns the color of mutliple ui into whatever HEX color value they entered. im doing this to help me find a color scheme and most color scheme websites use HEX.

HOWEVER: i am OK with not using HEX if its to much trouble (just mention it!)

code:

local panel = script.Parent.Parent.Parent.panel
local GameUi = panel.Parent

local background1 = GameUi:FindFirstChild("Inventory")
local background2 = GameUi:FindFirstChild("Trade")
--


local trade = background2:FindFirstChild("Trade")
local Tbutton = trade:FindFirstChild("Tbutton")

local trade2 = background1:FindFirstChild("Trade")
local Ebutton = trade2:FindFirstChild("Ebutton")
--

local coins = GameUi:FindFirstChild("Coins")
local buttons = GameUi:FindFirstChild("Buttons")












local backgroundframe1 = background1
local backgroundframe2 = background2
	--
local buttonframe1 = Tbutton
local buttonframe2 = Ebutton
	--
local secondaryframe1 = coins
local secondaryframe2 = buttons
	
	
	
	
	
	--
	--
	--
	--
	--
	--
	--
	--
	
	
	
	
local background_color = script.parent:WaitForChild("backgroundColorTextBox")
local button_color = script.parent:WaitForChild("buttonColorTextBox")
local secondary_color = script.parent:WaitForChild("secondaryColorTextBox")

script.parent.MouseButton1Click:Connect(function()
	backgroundframe1.backgroundcolor = Color3.fromhex(background_color.Text)
	backgroundframe2.backgroundcolor = Color3.fromhex(background_color.Text)
	--
	buttonframe1.backgroundcolor = Color3.fromhex(button_color.Text)
	buttonframe1.backgroundcolor = Color3.fromhex(button_color.Text)
	--
	secondaryframe1.backgroundcolor = Color3.fromhex(secondary_color.Text)
	secondaryframe2.backgroundcolor = Color3.fromhex(secondary_color.Text)
end)

image:

after pressing apply changes it does nothing

here is the MODEL to the UI!

Thank you <3

Could you try to repost the model? It looks corrupted when I put it in my workspace.

sure. it could be corrupt becuase i used a plugin that resizes it for different screens

Does this one work? if it doesnt i have another idea

edit: i just tested it and it works. make sure not to move it and put it in starter gui

Can you put it on sale? It doesn’t let me get it.

reload page. it should be working!

This should work: (idk why you have so many unnecessary variables though.)

--//Variables
local panel = script.Parent.Parent.Parent.panel
local GameUi = panel.Parent

local background1 = GameUi:FindFirstChild("Inventory")
local background2 = GameUi:FindFirstChild("Trade")

local trade = background2:FindFirstChild("Trade")
local Tbutton = trade:FindFirstChild("Tbutton")

local trade2 = background1:FindFirstChild("Trade")
local Ebutton = trade2:FindFirstChild("Ebutton")

local coins = GameUi:FindFirstChild("Coins")
local buttons = GameUi:FindFirstChild("Buttons")

local backgroundframe1 = background1
local backgroundframe2 = background2

local buttonframe1 = Tbutton
local buttonframe2 = Ebutton

local secondaryframe1 = coins
local secondaryframe2 = buttons

local background_color = script.parent:WaitForChild("backgroundColorTextBox")
local button_color = script.parent:WaitForChild("buttonColorTextBox")
local secondary_color = script.parent:WaitForChild("secondaryColorTextBox")

--//Functions
script.parent.MouseButton1Click:Connect(function()
	backgroundframe1.BackgroundColor3 = Color3.fromHex(background_color.Text)
	backgroundframe2.BackgroundColor3 = Color3.fromHex(background_color.Text)
	
	buttonframe1.BackgroundColor3 = Color3.fromHex(button_color.Text)
	buttonframe1.BackgroundColor3 = Color3.fromHex(button_color.Text)
	
	secondaryframe1.BackgroundColor3 = Color3.fromHex(secondary_color.Text)
	secondaryframe2.BackgroundColor3 = Color3.fromHex(secondary_color.Text)
end)

Resources, client scripts, and server scripts should be managed separately. Otherwise it looks messy.

have you tested it yet? also HEX like what i put in the image i included in the post will work right?

edit: yea it doesnt seem to be working. maybe im using wronge hex? i changed the text to #4b26df
#4b26df
#4b26df

I haven’t tested it yet but it should work with the hex in your image.

企业微信截图_16391086735886

not all of them are images. maybe thats messing it up? no errors though

It’s not supposed to be an image. Can you try to maybe get rid of some variables so its easier for me to read and understand your code? Also, the UI that you put is still glitched for me.

local panel = script.Parent.Parent.Parent.panel
local GameUi = panel.Parent

local background1 = GameUi:FindFirstChild("Inventory")
local background2 = GameUi:FindFirstChild("Trade")
--


local trade = background2:FindFirstChild("Trade")
local Tbutton = trade:FindFirstChild("Tbutton")

local trade2 = background1:FindFirstChild("Trade")
local Ebutton = trade2:FindFirstChild("Ebutton")
--

local coins = GameUi:FindFirstChild("Coins")
local buttons = GameUi:FindFirstChild("Buttons")












local backgroundframe1 = background1
local backgroundframe2 = background2
	--
local buttonframe1 = Tbutton
local buttonframe2 = Ebutton
	--
local secondaryframe1 = coins
local secondaryframe2 = buttons
	

	
	
	
local background_color = script.parent.parent:WaitForChild("Background")
local button_color = script.parent.parent:WaitForChild("Buttons")
local secondary_color = script.parent.parent:WaitForChild("Secondary")

script.Parent.MouseButton1Click:Connect(function()
	pcall(function() -- SO if the Hex is wrong then it doesnt error
		backgroundframe2.BackgroundColor3 = Color3.fromHex(background_color.Text)
		--
		buttonframe1.BackgroundColor3 = Color3.fromHex(button_color.Text)
		buttonframe1.BackgroundColor3 = Color3.fromHex(button_color.Text)
		--
		secondaryframe1.BackgroundColor3 = Color3.fromHex(secondary_color.Text)
		secondaryframe2.BackgroundColor3 = Color3.fromHex(secondary_color.Text)
	end)
end)

Even Though The Image Might Cover It…
Here try this to see if it works MCQUEEEN
@KrimsonWoIf

--

--essentials

local panel = script.Parent.Parent.Parent.panel

local GameUi = panel.Parent

--

--

--

--background

local inventory = GameUi:FindFirstChild("Inventory") --used in buttons area to change color of this property

local Trade = GameUi:FindFirstChild("Trade")

local menu = Trade:FindFirstChild("menu")

--

--

--

--buttons (e/t buttons located inside trade/menu)

local Ebutton = inventory:FindFirstChild("Ebutton")

local Tbutton = Trade:FindFirstChild("Tbutton")

--

--

--

--secondary colors

local coins = GameUi:FindFirstChild("Coins")

local buttons = GameUi:FindFirstChild("Buttons")

--

--

--//Functions

script.parent.MouseButton1Click:Connect(function()

print("clicked")

--

--background colors

inventory.BackgroundColor3 = Color3.fromHex(script.parent:WaitForChild("backgroundColorTextBox").Text)

Trade.BackgroundColor3 = Color3.fromHex(script.parent:WaitForChild("backgroundColorTextBox").Text)

--

--buttons

Ebutton.BackgroundColor3 = Color3.fromHex(script.parent:WaitForChild("buttonColorTextBox").Text)

Tbutton.BackgroundColor3 = Color3.fromHex(script.parent:WaitForChild("buttonColorTextBox").Text)

--

--secondary colors

coins.BackgroundColor3 = Color3.fromHex(script.parent:WaitForChild("secondaryColorTextBox").Text)

buttons.BackgroundColor3 = Color3.fromHex(script.parent:WaitForChild("secondaryColorTextBox").Text)

end)

aren’t you going to test the code I sent to see if it worked? ;-;

sorry didnt see it. testing right now

also the image might just cover the color so :sweat:

hey, the code isnt really working. if you want im perfectly ok giving up on HEX. you might also want to open up the model i made since we could always be calling something incorrectly and we dont know it /shrug

I actually used the model and it worked fine for me with my code