"Invalid table key type used" When Firing RemoteFunction

Going to add a gotcha that recently popped up for me to help people in the future.

If you attempt to send a table over a remote with this format:

{
    string = {
        5, 2, 7, 2345
    }
}
-- or --
{
    string = {
        [1] = 5;
        [2] = 2;
        [3] = 7;
        [4] = 2345;
    }
}

… it will successfully be passed over the client-server boundary.
However, if you try to send a table with the following format:

{
    string = {
        [2] = "element";
        [3] = "element #2";
        [4] = "element #3";
    }
}

… it will fail to pass. The numeric indices must be in numeric order, starting from 1. I’m not sure how often it is encountered by others but it was annoying enough to warrant me typing this out.

27 Likes