Can't call function inside of table?

How do I find a function with a value iterated through a loop. Not sure if I said that write but code will pretty much explain.

self.AnimationFunctions = {
	["Dash"] = function(distance)
		print(distance)
	end,		
	["Stun"] = function(amount)
		print(amount)
	end,
}
for i, v in pairs(Events) do
	self.Combos[attack[self.Current].Track:GetMarkerReachedSignal(tostring(v)):Connect(function(value)
        print(v) -- Prints Dash
	    self.AnimationFunctions[v](value) -- Attempted to call nil value.
	end)
end

what is your events table?
and print the value see what it shows from the getmarketreachedsignal


The value prints out 5, as the parameter is and the events table is a table which contains all of the animation events in an animation track. And V prints out the event name.

What is the variable type of v using typeof()?

If it’s an animation track instance you might need to do v.Name to get the name as a string value.

It’s an instance because its an animation marker/event, so I tried to use .Name next but it still prints out the same error.


Did you print out the self.AnimationsFunctions table to make sure the function is there as intended?

Did you do an print equality check to make sure the key is the same?

print(v,"Dash", v.Name == "Dash")
1 Like


I’m confused?

Screen Shot 2022-07-25 at 7.37.28 PM
Apparently, it’s extremely sensitive, there was one more space next to dash.

Thank you for your help, I had no idea you could debug this way as well.

1 Like