So I have a RemoteFunction for the client to use to get the player’s current loadout. Everything works fine except for the fact that one index is being sent as nil. Here is the array from the server just before returning the array
08:10:46.185 {
[1] = {
[1] = "http://www.roblox.com/asset/?id=6196635213",
[2] = "http://www.roblox.com/asset/?id=6196635213",
[3] = {
[1] = Black MichAccessory
}
},
[2] = {
[1] = "rbxasset://textures/ui/GuiImagePlaceholder.png",
[2] = "M4A1",
[3] = 0
},
[3] = {},
[4] = {}
} - Server - Main:208
As you can see [1][3] has an array inside it but here is the client output
08:10:46.222 {
[1] = {
[1] = "http://www.roblox.com/asset/?id=6196635213",
[2] = "http://www.roblox.com/asset/?id=6196635213",
[3] = {}
},
[2] = {
[1] = "rbxasset://textures/ui/GuiImagePlaceholder.png",
[2] = "M4A1",
[3] = 0
},
[3] = {},
[4] = {}
} - Client
Here you can see that [1][3] is empty. Does anyone know why this happens?
Here is the server code
game.ReplicatedStorage.Remotes.GetPlayerCurrentLoadout.OnServerInvoke = function(player)
local PlayerLoadout = {{}, {}, {}, {}}
local team
if player.Team == game.Teams.BluFor then team = "BluFor" else team = "OpFor" end
local CurrentLoadout = player.Data[team].CurrentLoadout
if CurrentLoadout.Outfit.Value == 0 then
local item = game.ServerStorage.GameData.Outfits:FindFirstChild(script.StarterItems[team.."Outfit"].Value)
PlayerLoadout[1][1] = item.ItemIds.Shirt.ShirtTemplate
PlayerLoadout[1][2] = item.ItemIds.Pants.PantsTemplate
local tempArray = {}
for i, accessory in pairs(item.Accessories:GetChildren()) do
tempArray[i] = accessory:Clone()
end
PlayerLoadout[1][3] = tempArray
else
local item = game.ServerStorage.GameData.Outfits:FindFirstChild(PlayerLoadout.Outfit.Value)
PlayerLoadout[1][1] = item.ItemIds.Shirt.ShirtTemplate
PlayerLoadout[1][2] = item.ItemIds.Pants.PantsTemplate
local tempArray = {}
for i, accessory in pairs(item.Accessories:GetChildren()) do
tempArray[i] = accessory:Clone()
end
PlayerLoadout[1][3] = tempArray
end
...
print(PlayerLoadout)
return PlayerLoadout
end
And here is the client code
local PlayerCurrentLoadout = game.ReplicatedStorage.Remotes.GetPlayerCurrentLoadout:InvokeServer()
print(PlayerCurrentLoadout)