According to this Devforum post and this ScriptingHelpers answer, I should be able to pass in a dictionary so long as it is only a dictionary not mixed with an array. I can still pair an array with a dictionary key though. However, when I call my RemoteFunction to get a table of inventory items generated by the server, all the tables are empty.
Server Code:
ReplicatedStorage = game.ReplicatedStorage
PlayerStorageEvents = ReplicatedStorage.PlayerStorageEvents
ServerStorage = game.ServerStorage
PlayerStorageEvents.GetInventory.OnServerInvoke = function(player)
--Generate the dictionary that will be sent back
local storage = {
["Inventory"] = {},
["Equipment"] = {},
["ActiveItems"] = {}
}
--Get the player's storage
local playerStorage = ServerStorage.PlayerStorage:FindFirstChild(player.Name)
--Populate the table with all the elements in these folders
if playerStorage ~= nil then
for i,v in pairs(playerStorage.Equipment:GetChildren()) do
storage["Equipment"][i] = v
end
for i,v in pairs(playerStorage.ActiveItems:GetChildren()) do
storage["ActiveItems"][i] = v
end
for i,v in pairs(playerStorage.Inventory:GetChildren()) do
storage["Inventory"][i] = v
end
end
return storage
end
Yet all these commands:
print(#game.ReplicatedStorage.PlayerStorageEvents.GetInventory:InvokeServer())
print(#game.ReplicatedStorage.PlayerStorageEvents.GetInventory:InvokeServer()["Inventory"])
return 0 and all these commands:
print(game.ReplicatedStorage.PlayerStorageEvents.GetInventory:InvokeServer()["Inventory"][0])
return nil
