Bindable event drops 0 index on table. Behaviour not mentioned anywhere in documentation.

I’m unsure whether this should be a bug report or not.

If you run the following code in a local script:

local bindableEvent = script.Event
local zeroIndexedTable = {
    [0] = "zero",
    [1] = "one",
    [2] = "two"
}
bindableEvent.Event:Connect(function(_table) 
    print(_table)
end)
bindableEvent:Fire(zeroIndexedTable)

It will output the table, but with the 0th index dropped.

I was working with buffers, and I indexed them from zero, doing stuff involving terrain generation. Due to this, a block in the chunk was missing.

It took me multiple hours to diagnose where the issue was.

If this isn’t a bug, please put this in the documentation next time.

Page URL: https://create.roblox.com/docs/scripting/events/bindable#argument-limitations

This is a known limitation. It has to do with tables passed via remote and bindable events needing to be either a list or a dictionary. Results are inconsistent when mixed table types. In this case, lists don’t have a 0 index.

If you pass a table of data, do not pass a mixed table of numeric and string keys. Instead, pass a table that consists entirely of key-value pairs (a dictionary) or entirely of numeric indices (an array).

All the documentation mentions is mixing keys.

This behavior is described in the url, this is more an issue about the behavior of the language (Lua and Luau) and not the documentation.

As you may know lua/luau arrays are indexed starting from one. When you break out of this pattern and introduce keys outside of this numeric range, it is now considered a mixed table with “key-value” pairs.

You are right, the documentation description does not accurately describe the case. I believe that essentially, under the hood it’s how the data is transcribed to json and back.

Hey all, this is my understanding, as well. If you check the length of the table after creating it, you’ll see that it returns 2, since manually assigning to 0 and then letting the rest of the table act as an array causes the “mixed table” that we warn against.

The documentation only mentions to avoid mixed tables, it doesn’t explain that it strips the dictionary portion. That’s the problem here, I think.

On a slightly related note, is there a more technical reason why it gets stripped? I know it’s for parity with remotes, but couldn’t they just serialize the dictionary part too?

Edit: The documentation should also mention that non-integer numbers get truncated and stringified.