Hey, So I am trying to make a system where the client asks via a remote event for a table stored in ServerStorage But there is an error that keeps popping up saying
"bad argument #1 to 'pairs' (table expected, got nil)"
I don't understand since it clearly has returned the table through the server script...
Here is the code
CLIENT SIDE
local plr = game:GetService("Players").LocalPlayer
local fooditems = game:GetService("ReplicatedStorage").FoodBooking.GetItems:InvokeServer(game:GetService("Players").LocalPlayer.PlrClass.Value)
for i,v in pairs(fooditems) do
print(v.Name)
end
SERVER SIDE
game:GetService("Players").PlayerAdded:connect(function(plr)
local class = Instance.new("StringValue",plr)
class.Name = "PlrClass"
class.Value = "EC"
end)
game:GetService("ReplicatedStorage").FoodBooking.GetItems.OnServerInvoke = function(pclass)
if game:GetService("ServerStorage").MenuItems.ShortHaul.Value == true then
return game:GetService("ServerStorage").MenuItems.SH:GetChildren()
else
if pclass == "EC" then
return game:GetService("ServerStorage").MenuItems.LH.EC:GetChildren()
elseif pclass == "BC" then
return game:GetService("ServerStorage").MenuItems.LH.BC:GetChildren()
end
end
end
Thanks.

1 comment
Then none of your if statements in your server side are being entered. Follow a breakpoint at the start of your server side script serverinvoked function and see where it goes.