I’m trying to make an order system, it’s going somewhat well until I got to the queue part and whatnot, so essentially, a variable called ‘staffMember’ is generated and it’s set to the first person in the queue. Now I want the staffMember to have gui that appears on their screen, However, when I fire the client and send the staff member, it appears on the client as nil. Code is below, both serverside and local side.
Server side:
game.ReplicatedStorage.OrderSubmitted.OnServerEvent:Connect(function(player, orderInfo, ordersTarget)
local submittedPlayer = player
local staffMember = nil
if #orderQueue > 0 and debounce == false then
debounce = true
staffMember = orderQueue[1]
table.remove(orderQueue, 1)
print(orderInfo)
print(staffMember, "-staffmember1")
for i, remainingPlayer in ipairs(orderQueue) do
game.ReplicatedStorage.UpdateQueuePosition:FireClient(remainingPlayer, i)
end
end
local ticketNum = currentTicket + 1
currentTicket = ticketNum
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
print(staffMember, "-staffmember2")
game.ReplicatedStorage.OrderRecieved:FireClient(player, staffMember, orderInfo)
wait(0.5)
debounce = false
return staffMember
end)
Local Script:
game.ReplicatedStorage.OrderRecieved.OnClientEvent:Connect(function(staffMember, orderInfo)
local localPlayer = game.Players.LocalPlayer
print(localPlayer.Name)
print(staffMember)
if localPlayer.Name == staffMember then
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
tool:Destroy()
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
end)
Am I doing this right or is there a better way to get the gui to appear on the staffmembers screen? The only way that was working for me was sending the ‘player’ (the player that created the order) as well, and I’m not sure why. I hope you can point out my errors.