Unwanted third argument is being required as a string in my function

Hi guys, hoping you can help me in this one, this error has been cracking my head for atleast 1 hour and I can’t seem to fix it in no way possible

Output:
image

AnimationsList.List = {

	Fists= {
		KeyName = "Bareknuckle",
		["IdleAnim"] = "rbxassetid://7960303328",
		["WalkAnim"] = "rbxassetid://8417014258"
	},

	Unequipped = { 
		KeyName = "Weaponless",
		["IdleAnim"] = "rbxassetid://7486396689",
		["WalkAnim"] = "rbxassetid://8418356862"
	},

	BaseballBat = { 
		KeyName = "Bat",
		["IdleAnim"] = "rbxassetid://8437882381",
		["WalkAnim"] = "rbxassetid://8418356862"
	}

}
---------------------------------------------------------------------------------------------here
AnimationsList.ReturnAnimation = function(AnimName, KeyName)  <-- this is the problem
	for Index, AnimSheet in ipairs(AnimationsList.List) do
		if AnimSheet.KeyName == KeyName then
			return AnimSheet[AnimName]
		end
	end
end

Solutions I tried:
-Emptying the entire function leaving only a print, still requires #3 string argument
-Changing function method, making it a separate function out of the table, still requires #3 string argument
-Changing the function’s name, still requires #3 string argument

Please help.

1 Like

Only thing I can think of is maybe print AnimName and KeyName in the function, see what is being passed to it.

It does not seem like this is the function causing the error.

1 Like

I used the script without the function it not being necessary to run, and it runs just fine, I tried to do everything to see if it’s something from outside the function but there’s nothing, it is the function for some reason.

1 Like

I’m wondering if the problem is not the function, but how you assign it. I have had some weird errors pop up as a result of syntax.

1 Like

I think the problem is with that in ipairs use in pairs instead

1 Like

This looks right. And to add on, ipairs means integer pairs (iirc) and corresponds to the values in an array, e.g. local a = {"b", "c", "d", e = f}, values b, c, d and not e/f since that is a dictionary element.

Since AnimationsList.List is a pure dictionary, you iterate over nothing.

2 Likes