BackgroundColor3 value of Frame Changes but Actual Color does Not

Hello, I am trying to change the background color of a frame from a script while in game.

The issue is that the BackgroudColor3 VALUE of the frame changes, but the actual COLOR stays green instead of turning red (from the new BackgroundColor3 value).

Here is a video explaining what happens:

BackgroundColor3 value of Frame Changes but Actual Color does Not - YouTube

Please note, in this video I changed the BackgroundColor3 value via the properties menu. My script yields the same result when run, so I am 99% sure it isn’t an issue with the script.

–

In case it matters, here is the code (for the “red” ImageButton, the script is called “colors test”):

local ui = game.StarterGui.CustomUI

function leftClick()
	print("leftClick")
	CustomUI(Color3.new(1, 0, 0))
end

function CustomUI(color)
	ui.Chat.BackgroundColor3 = color
	ui.Main.BackgroundColor3 = color
	ui.Extra.BackgroundColor3 = color
	ui.Settings.BackgroundColor3 = color
	ui.Timer.BackgroundColor3 = color
	print(color)
end



script.Parent.MouseButton1Click:Connect(leftClick)

and here is a screenshot of the relevant part of the explorer:
image

I’ve tried setting the “Chat” frame’s Active value to true and messing with the script, but nothing has been working. I’ve looked through the internet as well, and I’m pretty frustrated at this point.

–

This is my first DevForum post, so please let me know if I did anything wrong in that regard.

Its because you put StarterUI

Instead of playerUi, so color changes in starterui not in playerui

type this:

function leftClick()
	print("leftClick")
	CustomUI(Color3.new(1, 0, 0))
end

function CustomUI(color)
    local ui = game.Players.LocalPlayer.PlayerGui.CustomUI
	ui.Chat.BackgroundColor3 = color
	ui.Main.BackgroundColor3 = color
	ui.Extra.BackgroundColor3 = color
	ui.Settings.BackgroundColor3 = color
	ui.Timer.BackgroundColor3 = color
	print(color)
end



script.Parent.MouseButton1Click:Connect(leftClick)
3 Likes

I’m pretty sure you can’t put UIS in the LocalPLayer and that you need to put in PlayerGui.

However, this is the code:

local ui = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("CustomUI")

function leftClick()
	print("leftClick")
	CustomUI(Color3.new(1, 0, 0))
end

function CustomUI(color)
	ui.Chat.BackgroundColor3 = color
	ui.Main.BackgroundColor3 = color
	ui.Extra.BackgroundColor3 = color
	ui.Settings.BackgroundColor3 = color
	ui.Timer.BackgroundColor3 = color
	print(color)
end

Also, use a LocalScript for this.

yeah i forgot to put it. i did now.

It is also better to use WaitForChild(), but only if the local script is instantly working, not including any wait but her code probably doesn’t use wait() in it.

You don’t need to add :WaitForChild()

because it triggers the thing when we click the button.

Isn’t it the idea? To do something when the LeftClick is pressed?

I created the ui variable when mousebutton click! but you also can put :WaitForChild() its up to you what thing you use! but if you want to make script clean and short you can use my trick.

You can check the new one here:

1 Like

maybe this can help, https: //developer.roblox.com/en-us/api-reference/class/Frame

as alex stated, this is what it does, to see the change, you’d have to reset