UI objects not showing up?

I’m making a color selector and, due to laziness, I didn’t want to manually make each button for every available color, so I made a quick and easy little system to automatically create the UI elements via a UIGridLayout:

local function initColorSelection()
	for i,v in pairs(colors) do
		local template = templates:FindFirstChild("ColorPlaceholder"):Clone()
		template.Parent = colorFrame
		template.Name = i
		template.Visible = true
		template.BackgroundColor3 = v.Color
	end
end
initColorSelection()

As you can see, it is very simple. It copies a UI element from a template and changes its properties a bit. One problem: The copied UI elements will not show up no matter what. I’ve tried changing zindex, visibility, and background transparency.

They are there, their properties are changed, and they’re in the right spot in my frame, but they’re not visible. I’ve changed the background transparency of every UI element in my game to no avail to see if it was a zindex issue, but they were still invisible.

Their .visible property is true, they aren’t transparent, and their ScreenGUI parent is enabled. What could be causing this?

Edit: If it helps, the frame I’m using is a gradient from the InterfaceTools plugin, though I compared it’s settings with those of a normal frame and they appeared to be the same. I’m also accessing the StarterGui service instead of referencing UI elements with script.Parent, as the script is located within a tool.

“colorFrame” is this defined somewhere?

yes, it’s just a frame where the colors are placed. Here are all the relevant variables:

local uiService = game:GetService("StarterGui")
local buildSettings = uiService:WaitForChild("BuildSettings") --my screengui

local main = buildSettings:WaitForChild("Main")
local templates = uiService:WaitForChild("Templates")
local colorFrame = main:WaitForChild("ColorFrame")
1 Like

What are you trying to do is to define the uiService as the games’ ui which does not update the GUI from the player screen, not from the client/player. You can do this by:

local plr = game:GetService("Players").LocalPlayers
local ui = plr:FindFirstChild("PlayerGui"):WaitForChild("BuildSettings")

Hopefully this helps.

1 Like

This worked, thank you so much :​)

Credit @gIwwinnq reply with the “solution” so that:

  1. they get recognized for their contribution
  2. future visitors can quickly see which reply was the solution that worked
  3. when scrolling through the posts, we can easily see this post as solved, and not click into it to try to continue helping you

:slight_smile: