Yes, you can pass a table through a RemoteEvent, but there are some complexities to this.
If you try to pass a dictionary with an array, the dictionary portion will be lost. Note that this only applies if they are in the same table at the same level, so you can nest an array in a dictionary or vice versa just fine.
This is okay to send through a remote:
local PlayerData = {
"hi",
{
test = "wow",
anotherKey = "we're in the dictionary"
}
}
This is also okay:
local PlayerData = {
key = "hi",
another = "value",
tryAnArray = {
1,
2,
"stringHere",
"moreNesting",
{
6,
7
},
{
tryingDictionary = 4,
again = 6
}
}
}
But this would lose the dictionary:
local PlayerData = {
hi = 4,
2
}
And if you try to pass a table with any key that is not a string, and if the table is not an array, it will error.
For example:
local PlayerIdToName = {
[1] = "ROBLOX",
[59299229] = "Avigant"
}
Though the 1 key will go inside the array, the 59299229 key won't be placed inside the array, so if you try to pass this table through a remote, it will error. This is important to keep in mind.
Instances that are values in the table will be set to nil if they do not exist on the computer you are firing the remote to. For example, if you send an object in game.ServerStorage to the client, it will be nil.
Functions cannot be passed through remotes. Userdata can. Metatables will be lost.
2 comments
Yes this works fine?
Well, it would work but you forgot and end on line 4