Remote function doesn't return table

im assuming remote function iterates through the table and that isn’t the result I wanted

im making an inventory system such as minecraft where there can be gaps between the items
unlike the arrays it does not have gaps between the indexes

here’s my problem

--on the server i automatically give players an item as soon as they join
Players.PlayerAdded:Connect(function(player)
	PlayerInventory[player.Name] = {'sword', [3]='gun'} -- first index and third index
	print(PlayerInventory)
end)
-- then on the client i request for the items
local playerInventory = GetPlayerInventory:InvokeServer()
warn(playerInventory)

--on the server it returns the items
GetPlayerInventory.OnServerInvoke = function(player)
	warn(PlayerInventory[player.Name])
	return PlayerInventory[player.Name]
end

images in order
image
image

but it works fine if i don’t skip the index in the table


image

nvm it works, i had to use string keys like
[“1”] = “gun”, [“3”] = “sword”

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.