Checking for non-playing animation tracks?

Hey, and thanks for reading in advance.

I’ve got a central module of common functions that the central clientscript uses in a fighting game I’m coding. One such function handles the creating and loading of new animations:

function Core:CreateAnim(Character, id, name)
	if Character and Character:FindFirstChild("Humanoid") then
		local Humanoid = Character.Humanoid
		local Animation, Track
		
		local Concat = "rbxassetid://"..id
		local Folder = script.Parent:FindFirstChild("Animations")
		
		if not Folder or not Folder:IsA("Folder") then
			Folder = Instance.new("Folder", script.Parent)
			Folder.Name = "Animations"
		end
		
		Animation = Folder:FindFirstChild(name) or Instance.new("Animation")
		Animation.AnimationId = "rbxassetid://"..id; Animation.Name = name
		Track = Humanoid:LoadAnimation(Animation)
		
		return Track
	end
end

I naively thought that loading an animation with an ID identical to a previously loaded track would just over-write the old track, until studio’s output told me I’d loaded over 256 animations and further could not be played.

Further still, tracks don’t appear in the explorer and don’t seem to be descendants of the Humanoid, and I can’t re-parent them due to the property being locked. It seems like my only option here is a table of loaded IDs to compare against, except, this is a module. Not the most optimal solution. I searched the API, but I didn’t find a built-in method of the Humanoid that would return tracks that are not currently playing.

So, I’m curious: is there some way to observe all loaded tracks on the Humanoid? Am I overthinking this?

Nope, you have to manually track those animations. Might be beneficial to make a dedicated animation handler for this purpose, or at least some way to make handling animations easier. It’s typically best to load a track once and then use it from thereon: LoadAnimation is often called often, even though it never really should be.

I see. That’s pretty gross. Seems easily solvable with the addition of a new method that acquires all tracks, but I guess there aren’t enough use-cases for it. Thanks again, colbert.