Why does this print 0? I really don't understand why.
local kRef = { ["w"] = Enum.KeyCode.W, ["a"] = Enum.KeyCode.A, ["s"] = Enum.KeyCode.S, ["d"] = Enum.KeyCode.D, ["space"] = Enum.KeyCode.Space } print(#kRef)
#keyRef
printed 0, because of how the keys are stored. In order to fix this, you should remove the dictionary's indexes and make it a normal table.local kRef = { Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D, Enum.KeyCode.Space } print(#kRef) --> 5
local kRef = { ["w"] = Enum.KeyCode.W, ["a"] = Enum.KeyCode.A, ["s"] = Enum.KeyCode.S, ["d"] = Enum.KeyCode.D, ["space"] = Enum.KeyCode.Space } --If you want to print all the table's contents, use a loop: for i, v in pairs(kRef) do print(v) end