I have a little animation function that will load a track by name into a AnimationController every time that animation is played, as the topic title states, would this cause memory leaks?
I do it this way because I believe the API only allows us to get playing tracks, not previously played tracks.
here is the code I am using
function ManageStand.PlayAnimation(params, animationName, animationSpeed)
local animationLength
local playerStandFolder = workspace.PlayerStands:FindFirstChild(params.InitUserId)
local targetStand = playerStandFolder:FindFirstChildWhichIsA("Model")
local animationController = targetStand:FindFirstChild("AnimationController")
if animationController then
local thisAnimation = ReplicatedStorage.StandAnimations:FindFirstChild(animationName)
if thisAnimation then
local newTrack = animationController:LoadAnimation(thisAnimation)
if animationSpeed then
newTrack:AdjustSpeed(animationSpeed)
end
newTrack:Play()
animationTime = newTrack.Length
end
end
return animationLength
end