Table not working

I’m tryng to learn about metatables

but for whatever reason the spells table seems to be empty when i print it since it says nil
Ekrānuzņēmums 2021-07-11 172639

Full code:

local spells = {
	["Fire Tornado"] = {
		insertDamage = 10,
		roundDamage = 15,
		castDelay = 15,
		manaConsumption = 45
	["Water Bomb"] = {
		explosionDelay = math.random(3,5),
		explosionDamage = 30,
		castDelay = 10,
		manaConsumption = 35


	__newindex = function(table, index)
		print("That spell does not exist!")
1 Like

You have created a dictionary, so calling [1] shouldnt be the right way of doing it

try this:

print(spells["Fire Tornado"])

it should print something along the lines of table #11y328 (A table with a identifier)

Oh right! I forgot that [number] is for arrays and not dictionary

And now it printed out all of the variables stored in it
Ekrānuzņēmums 2021-07-11 173800

Yea, just try to remember you have to stick with the format a variable is created in, unless it can be converted into another value type.

I try to stick with only arrays and don’t use dictionaries for this very reason. (Plus arrays are a lot better for moving data around as well as accessing it)