ReplicatedStorage.Modules._OrderMenu:13: attempt to index nil with 'GetChildren' - Client - _OrderMenu:13

I’m making an order system, where the player can order from the menu, and it will pop up on a ScreenGui. For some reason I keep getting the error in the title, could anyone help?

I’m also not very good at returning, could someone also confirm I’m using returning correctly?

local OrderMenu = {}

local repStorage = game:GetService("ReplicatedStorage")
local modules = repStorage:WaitForChild("Modules")

local queueModule = require(modules:FindFirstChild("_Queue"))
local frameSample = repStorage:WaitForChild("OrderSample")

local Players = game:GetService("Players")

local function getChildrenOfClass(_uiSample, class)
	local returnedClass = {}
	for index, v in pairs(_uiSample:GetChildren()) do
		if v:IsA(class) then
			table.insert(returnedClass, v)
		end
	end
	return returnedClass
end

OrderMenu._UpdateClients = function(player, orderItem)
	local playerGui = player.PlayerGui
	local orderBack = playerGui.OrderGui.Back
	local orderScrollingFrame = orderBack.ScrollingFrame
	local orderSample = frameSample:Clone()
	
	local nonQueueItems = getChildrenOfClass(orderScrollingFrame, "Frame")
	local _amountOfNonQueueItems = #getChildrenOfClass()
	
	local _samplePositions = {
		UDim2.new(0.029, 0,0.039, 0);
		UDim2.new(0.026, 0,0.391, 0);
		UDim2.new(0.027, 0,0.752, 0)
	}
	
	if _amountOfNonQueueItems < 3 then
		orderSample.PlayerName.Text = player.Name
		orderSample.OrderItem.Text = orderItem
		
		local thumbType = Enum.ThumbnailType.HeadShot
		local thumbSize = Enum.ThumbnailSize.Size420x420
		local content, isReady = Players:GetUserThumbnailAsync(player.UserId, thumbType, thumbSize)
		
		orderSample.PlayerAvatar.Image = content
		
		orderSample.Position = UDim2.new(_samplePositions[_amountOfNonQueueItems])
	end
end

return OrderMenu

The first parameter you’re passing through this function is nil getChildrenOfClass(_uiSample, class)

2 Likes

How is that nil? When I called it I passed through 2 parameters

Passing 2 parameters to a function does not guarantee they are not nil. Check where you’re calling the function because the issue is there.

What is class, because I don’t see it.

1 Like

It’s in the function parameters

Print out orderScrollingFrame before it goes through the function to check if it’s nil or not

1 Like

Nevermind, still gives the same error.

Is it printing out nil?

All good, fixed everything, thanks for the help.

1 Like