I'm making a script for a sword right now, and I stockpiled a bunch of useful animations in it, the sword, once equipped, uses a local function to return a table containing all animations, where the key values are the names of each animation, and any subfolders are named tables within a table, I just re-wrote the script because something wasn't working right and the subfolder items weren't being put into the tables within the main table, and now its not working, the function goes into an infinite recursion... :/

local Tool = script.Parent;
local TempAnis = Tool.Handle.Blah;	--[ The animations are all stored in folders within the handle of the tool. ]
local Anims = nil;

local function LoadAnims(Prnt, Dest)
	print("Checking ".. Prnt.Name .."...")
	if #Prnt:GetChildren() > 0 then
		for Val, Itm in pairs(Prnt:GetChildren()) do
			if not Dest[Itm.Name] or Dest[Itm.Name] == nil then
				if type(Itm) == "userdata" and Itm:IsA("Animation") then
					Dest[Itm.Name] = Hum:LoadAnimation(Prnt:WaitForChild(Itm.Name))
					print(Itm.Name .." of type: "..type(Itm) .."; was added to Array.")
				else
					Dest[Itm.Name] = {}	--[ New table creation, theres a secondary function I re-wrote to handle the accidental happening of subfolder-tables being empty, but thats not needed here. ]
					return LoadAnims(Prnt, Dest[Itm.Name])
				end
			else break end
		end
	else
		print("No children found...")
	end
	return Dest	--[ The function is meant to return a table so I can set the variable 'Anims' below to be used. ]
end
Anims = LoadAnims(TempAnis, {})

I should also mention, the function 'LoadAnims()' is within another function, the standard 'OnEquipped' function.

Any help or insight is appreciated... ;~;

4 comments

0

Why did you make your own WaitForChild?

0

local WaitForChild = game.WaitForChild; That was easy.

0

I fixed the WaitForChild, but the script still has infinite recursion... any different suggestions?...

0

Neeever mind... I found the error... :| I forgot to change "Prnt" in the return function to "Itm"... Ugh.