I have this GUI in my game that when it is clicked, it opens up a Frame that shows multiple clickable color boxes. The script is supposed to change the TextLabel color to the color the player clicked. I have been approaching it in different ways, but they all come out with a different outcome. Either the color boxes appear, and the clickable part doesn't work, or the color boxes don't appear at all. I would appreciate your help. Thank you.
Player = game.Players.LocalPlayer
--
RS = game:GetService("ReplicatedStorage")
GFiles = RS:WaitForChild("GuiFiles")
Rank = GFiles:WaitForChild("Rank")
Events = RS:WaitForChild("Events")
ColorUI = script.Parent:WaitForChild("ColorUI")
ColorsBox = ColorUI:WaitForChild("Main"):WaitForChild("Colors")
ColorButton = script.Parent:WaitForChild("ChangeColor")
RankGui = nil
local open = false
while not game.Players.LocalPlayer do
wait()
end
while not workspace:FindFirstChild(tostring(game.Players.LocalPlayer)) do
wait()
end
-- The problem seems to be in the function LoadColors(), but it does not show any script errors. This function below makes the colors appear, and is supposed to change the TextColor of the TextLabel to the color the player clicks.
function LoadColors()
local Colors = {1001,119, 24, 106, 21, 104, 23, 107, 37, 1002, 194, 199, 26, 1003, 1022, 105, 125, 153, 1023, 135, 102, 151, 5, 336, 1005, 101, 9, 11, 1018, 39, 1030, 1029, 1025, 1016, 1026, 1024, 1027, 1028, 1008, 1009, 1017, 1004, 1032, 1010, 1019, 1020, 217, 18, 38, 1031, 1006, 1013, 45, 1021, 192, 1014, 1007, 1015, 1012, 1011, 28, 141}
local LoadingColors = true
local BuffLoadLimit = 10
local CurrentLoad = 0
local PrevPosition = UDim2.new(-0.1, 0, 0, 0)
for Int,Color in pairs(Colors) do
local NewColor = script:WaitForChild("ColorExample"):Clone()
if PrevPosition.X.Scale >= (1 - 0.1) and PrevPosition.Y.Scale >= (1 - 0.1) then
LoadingColors = false
elseif PrevPosition.X.Scale >= (1 - 0.1) then
NewColor.Position = UDim2.new(0, 0, PrevPosition.Y.Scale + 0.1, 0)
else
NewColor.Position = PrevPosition + UDim2.new(0.1, 0, 0, 0)
end
NewColor.BackgroundColor3 = script:WaitForChild("ColorExample"):Clone().BackgroundColor3.Color
NewColor.Parent = ColorsBox
NewColor.Visible = true
NewColor.MouseButton1Down:connect(function()
print("User clicked button")
local RankGui = Player.Character:findFirstChild("Rank")
if RankGui == nil then return end
print"Found gui"
if RankGui:FindFirstChild("Frame").Name1.TextColor3 ~= nil then
local CurrentColor = RankGui.Frame.Name1.TextColor3
print("Found color")
for i,v in pairs(RankGui.Frame:WaitforChild("Name1")) do
if v:IsA("TextButton") and v.TextColor3 == CurrentColor then
v.TextColor3 = NewColor.BackgroundColor3.Color
end
end
RankGui.Frame.Name1.TextColor3 = NewColor.BackgroundColor3.Color
ColorUI.Visible = false
end
end)
PrevPosition = NewColor.Position
CurrentLoad = CurrentLoad + 1
if CurrentLoad >= BuffLoadLimit then
wait(0.001)
CurrentLoad = 0
end
end
end
ColorButton.MouseButton1Click:connect(function()
open = not open
if open then
ColorUI.Visible = true
else
ColorUI.Visible = false
end
end)
LoadColors()
Thank you!

3 comments
If the Color table store the Color3 Value then those value's in can't be larger then 255.
line 52 BackgroundColor3 is already a color, tell me if that's the error
No, that did not do anything.