:Destroy() is deprecated?? Since when
Itâs not technically deprecated, itâs kind of got the same treatment as âwait()â did.
Debris is SLIGHTLY better than using â:Destroy()â and the documentation explains it here:
I just saw your on HD Discord server its me lol, donât make me look like an idiot XD. Donât tell them it was me.
By the way donât tell them english is my first language theyâre going to absolutely violate me in that chat.
uh yeah, when you call :LoadAnimation()
on your animator, it returns an AnimationTrackâ
which you can then store in a table or something and destroy when itâs no longer needed. This basically âunloadsâ the animation track from the animator
Wrote some simple code for you to work off:
--animtion track function to load an animation on the animator
local function _loadAnimation(animationTarget : Animator, animationID : string) : AnimationTrack
local newAnimation = Instance.new("Animation")
newAnimation.AnimationId = animationID
return animationTarget:LoadAnimation(newAnimation)
end
local animator = localPlayer.Character.Humanoid.Animator
--this is an animation track object
--you can store it wherever to then destroy/unload
local yourAnimationTrack = _loadAnimation(animator, "rbxassetid://0000000000")
--play the animation normally
yourAnimationTrack:Play()
--wait for your animation to stop playing
yourAnimationTrack.Stopped:Wait()
--to destroy/unload just do this
yourAnimationTrack:Destroy()
yourAnimationTrack = nil
I know how load animation and animation tracks work, I was just wondering if destroying/deleting/removing the tracks from my table is the same as getting âunloadedâ and will free up the space of the 256 animation tracks allowed to be loaded. You didnât need to provide a whole code block lol
yes itâs the same, but remember to also clear the reference in the table too. This is how:
--create a table to hold the animation tracks
local animationTable = table.create(256)
--add the animation track to the table you created
local yourAnimationTrack = _loadAnimation(animator, "rbxassetid://0000000000")
table.insert(animationTable, yourAnimationTrack)
--how to clear from a table
table.remove(animationTable, table.find(animationTable, yourAnimationTrack))
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.