This is by design, the wiki states
If a Table is passed as an argument to a BindableEvent it must be an array without missing entries or have string keys, not a mixture, or else the string keys will be lost.
This is by design, the wiki states
If a Table is passed as an argument to a BindableEvent it must be an array without missing entries or have string keys, not a mixture, or else the string keys will be lost.
Personally feel like this is a bug, if it’s going to be culling keys it should either error or warn to let us know. It errors for other cases.
local tab = {};
tab[1] = 1;
tab[2] = 2;
tab[3] = 3;
-- tab[4] = 4;
tab[2] = nil;
print(game.HttpService:JSONEncode(tab));
Run this and it will give you [1]
. It should give you [1, null, 3]
. Now uncomment the commented line. It will give you [1, null, 3, 4]
as expected.
Note that this affects DataStores and RemoteFunctions/RemoteEvents. Please fix soon.
Yet the following code works:
script.Event.Event:connect( function ( t )
for a, b in pairs( t ) do print( a, b ) end
end )
script.Event:Fire( { 1, nil, 3 } )
>1 1
>3 3