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).
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:
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.
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)
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
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.
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.