UI not appearing on part when SurfaceGUI is placed in StarterGUI and Adornee is set

I have scripted a system where orders generate and appear on the board, however, when I needed to put a local script in the generated slots, they could not longer be placed under the workspace. So, I put the surfaceGUI in the StarterGUI and properly set up the adornee. Now, the generated orders do not appear.

For those looking for the script in charge of generating and displaying orders, I’ve also provided the script:

-- Services --

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGUI = game:GetService("StarterGui")
-- Variables --

local orderBoard = workspace:WaitForChild("OrderBoard")

local orderSystem = require(script:WaitForChild("OrderSystem"))

local orderNumber = 0

-- Order Function --

orders = {}
currentOrders = {}

local function createOrder()
	local generatedBodyShape, generatedWoodType, generatedFretboard = orderSystem.generateOrder()
	
	local bodyShape = generatedBodyShape
	local woodType = generatedWoodType
	local fretboard = generatedFretboard
	
	table.insert(orders,{bodyShape,woodType,fretboard})
end

-- Display Orders --

local orderSlot = ReplicatedStorage:WaitForChild("OrderSlot")

local OrderSurfaceGui = StarterGUI:WaitForChild("OrderSurfaceGui")
local backgroundFrame = OrderSurfaceGui:WaitForChild("BackgroundFrame")

local function displayOrder()
	for _, order in pairs(orders) do
		local slot = orderSlot:Clone()

		local bodyShape = order[1]
		local woodType = order[2]
		local fretboard = order[3]
		
		slot.Parent = backgroundFrame
		
		-- Order Information --
		
		if tostring(bodyShape) == "LesPaulCustom" then
			slot.OrderName.Text = "Les Paul Custom"
		elseif tostring(bodyShape) == "LesPaul" then
			slot.OrderName.Text = "Les Paul"
			
		elseif tostring(bodyShape) == "FlyingV" then
			slot.OrderName.Text = "Flying V"
		else
			slot.OrderName.Text = tostring(bodyShape) 
		end

		slot.WoodType.Text = "<b>Woodtype:</b> "..tostring(woodType)
		slot.Fretboard.Text = "<b>Fretboard:</b> "..tostring(fretboard)
		
		table.remove(orders,tonumber(order))
	end
end

-- Order Generator --

while true do
	task.wait(math.random(1,5))
	
	if orderNumber == 8 then
		repeat task.wait(0.8) until orderNumber <= 8
		print("Maximum orders reached!")
	else
		createOrder()
		displayOrder()
		
		orderNumber = orderNumber + 1
	end
end

LocalScripts don’t work in the explorer, so maybe try to put it somwhere else like ScreenGui?

That’s not what I’m referring to. The script shown above is a server-side script.

The contents inside StarterGUI get cloned into the Player’s PlayerGui when that player’s character is loaded. If you’re trying to dynamically modify the contents inside whatever GuiObject you have in StarterGui and it’s something you want the player to witness on the spot, you’re going to have to use the player’s PlayerGui instead to make those changes.

Thank you very much! That helped a lot.

1 Like

Try changing it with a localscript since scripts don’t work with that

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.