FireClient Information Not Sending Properly

So I’m making this order system long story short, I’m trying to fire the client and send the following things: player, staffMember, orderInfo, orderFolder. Everything comes through fine except for orderFolder, am I making a type or is it just one of those days? Please someone help, code linked below. On the client side, it’s printing orderFolder as ‘nil’

Server Side Script:

game.ReplicatedStorage.OrderSubmitted.OnServerEvent:Connect(function(player, orderInfo, ordersTarget)
	local staffMember = nil

	if #orderQueue > 0 then
		staffMember = orderQueue[1]
		table.remove(orderQueue, 1)

		print(orderInfo)

		for i, remainingPlayer in ipairs(orderQueue) do
			game.ReplicatedStorage.UpdateQueuePosition:FireClient(remainingPlayer, i)
		end
	end

	local ticketNum = currentTicket + 1
	currentTicket = ticketNum
	
	local orderFolder = Instance.new("Folder")
	orderFolder.Name = "Order_" .. ticketNum
	orderFolder.Parent = game.ServerStorage
	
	orderFolders[ticketNum] = orderFolder

	if staffMember then
		local char = game.Workspace:FindFirstChild(ordersTarget)
		local ticketNumDisplay = script.TicketNumDisplay:Clone()
		ticketNumDisplay.Frame.Name1.Text = "Ticket #" .. ticketNum
		ticketNumDisplay.Parent = char:WaitForChild("Head")
	end
	
	game.ReplicatedStorage.OrderRecieved:FireClient(player, staffMember, orderInfo, orderFolder)

	return staffMember
end)

Local Script:

game.ReplicatedStorage.OrderRecieved.OnClientEvent:Connect(function(staffMember, orderInfo, orderFolder)
	notiText.Text = "Order Received!"
	notificationFrame.Visible = true
	notiSlideIn(notificationFrame)

	orderDisplayFrame.Visible = true
	orderSlideIn(orderDisplayFrame)

	if type(orderInfo) == "table" then
		for key, itemFrame in ipairs(itemFrameHolder) do
			local orderIndex = key - 1  -- Adjust the index to match Lua indexing
			if itemFrame:IsA("TextLabel") and orderInfo[orderIndex] then
				itemFrame.Text = orderInfo[orderIndex]
			end
		end
	else
		print("Received orderInfo is not a table.")
	end

	addItemButton.MouseButton1Click:Connect(function()
		if itemsAdded < #orderInfo then
			itemsAdded = itemsAdded + 1
			local tool = staffMember.Character:FindFirstChildOfClass("Tool")

			if tool then
				local itemName = tool.Name
				print(itemName)

				for key, itemFrame in ipairs(itemFrameHolder) do
					if itemFrame:IsA("TextLabel") then
						if itemFrame.Text == itemName then
							print(orderFolder)
							tool.Parent = orderFolder

							itemFrame.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
							break
						end
					end
				end
			end
			if itemsAdded == #orderInfo then
				addItemButton.Text = "Submit"
			end
		elseif itemsAdded == #orderInfo then
			orderSlideOut(orderDisplayFrame)

			for key, itemFrame in ipairs(itemFrameHolder) do
				if itemFrame:IsA("TextLabel") then
					wait(1)
					itemFrame.BackgroundColor3 = Color3.new(1, 1, 1)
					break
				end
			end

			addItemButton.Text = "Add Item"

			print('Order submitted!')
		end
	end)

	wait(3)
	notiSlideOut(notificationFrame)
end)

Thank you!

1 Like

I haven’t read your code, but the server cannot pass server-side objects to the client, assuming “orderFolder” is a folder instance. You’ll instead have to either move the folder to a public location (available to the client) or serialize the data it contains and send it that way.

Alternatively, you can have the server directly clone the folder into the client somewhere such as their PlayerGui, which will prevent any other client from viewing it accept for that client. The only issue there is removing it client-side will not remove it on the server’s side.

1 Like