Expected '(' when parsing function

why is this happeing?

local bossAttacks = {
	
 	function attack1()
		RisingSpikes()
	end,
	
	function attack2()
		fireBall()
	end
}

Try this:

local bossAttacks = {
	attack1 = function()
		RisingSpikes()
	end,
	attack2 = function()
		fireBall()
	end
}

is the functionality the same?

Yes, it does the same, the order was wrong.

1 Like

You can also just add the functions in without writing them directly to the table. Here is an example of how I usually do it.

local funcs = {}

funcs.Function1 = function(...)
	print(...)
end

funcs.Function1("Function in a table")

I believe the primary problem with your code is that you are writing in for a new index but not providing any kind of value, which is required. SOTR654 has provided the correct format.

A function inside of a table needs to act like a dictionary, your format tries to make it an array.

2 Likes