Idk why it don’t work here is code :
local aTable = {Enum.KeyCode.E, Enum.Keycode.R}
print(aTable[Enum.KeyCode.E])
it print “nil” can someone explain.
Idk why it don’t work here is code :
local aTable = {Enum.KeyCode.E, Enum.Keycode.R}
print(aTable[Enum.KeyCode.E])
it print “nil” can someone explain.
You are setting it as a value in the table, and then trying to get a value associated with it as a key. Since you’re not setting anything as a value with the Enum as the key—you’re just setting the key at 1 to the Enum—indexxing the table with the Enum won’t find anything. If you want to search a table’s values, use table.find
.
Edit: I reread my post and it was a bit unclear, so here’s a visual explanation:
Key | Value |
---|---|
1 | Enum.KeyCode.E |
2 | Enum.KeyCode.R |
What’s the value associated with the key of Enum.KeyCode.E in the table? There’s nothing there, so nil
.