Table.Insert() is giving me the attempt to call table value error

I am attempting to make a dictionary using table.insert(), the table is initially blank and it tries to add two new sections to it but it gives me that error, below is information on it.
I have removed sections not needed from the AttackData, below is the data I am trying to insert in and after that is the table.insert.

				["PhasesThatHaveModifiers"] = {"Circle", "Pause"}
					["Activation"] = {
						["Chance"] = 0.1,
						["Modifier"] = 0.1
					},

	modifierPhases = {}
	for i, v in pairs(AttackData["Temp"]["Haywire"]["Settings"]["PhasesThatHaveModifiers"]) do
		table.insert(modifierPhases, {[v] = AttackData["Temp"]["Haywire"]["PhaseSettings"][v]["Activation"]{"Chance"}})
	end
1 Like

If

 AttackData["Temp"]["Haywire"]["PhaseSettings"][v]["Activation"]

is a table and you are trying to index it with "Chance", then you should change {"Chance"} to [“Chance”]. If you put a table constructor such as {“Chance”} in the end of another expression, it is interpreted as a function call with the table being the only argument given to the function and the value of the expression before the table constructor being the function.

Does this work?

modifierPhases = {}
for i, v in pairs(AttackData["Temp"]["Haywire"]["Settings"]["PhasesThatHaveModifiers"]) do
	table.insert(modifierPhases, {[v] = AttackData["Temp"]["Haywire"]["PhaseSettings"][v]["Activation"]["Chance"]})
end

Edit: At first I forgot to actually make the change in the code :man_facepalming:, does it work now?

1 Like

Same error still unfortunately, the Chance part is in the table as shown by the top of the Lua code so I don’t think it’s that

Literally just immediately figured it out somehow lol, I appreciate the help you tried to give though

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.