I have some animations played on the server that I would like to pre-load.
Should they be preloaded on the client or in the server?
I’m not sure about this, but I preload it on both. I’m sure there’s a better method out there and I’m pretty inexperienced with asset preloading but I just load the animations in both a localscript and serverscript with the animations in ReplicatedStorage.
Preload where you’re gonna play them.
Can you elaborate on your definition of ‘preloading’?
Just make them ready to play, so the first time they play during the game it doesnt come delayed.
I have been preloading them on the server but I might have been doing something wrong as, as a player, if I join the game after a while of not doing so, the animations may still be loading…
What I do is: local animRef = animator:LoadAnimation(animationReference)
when the character spawns (humanoid/animator is created).
Then you use that reference for as long as the character is spawned.
Make sure to clean it (or overwrite it) once the character respawns.
If the script is a character script the cleanup should be handled automatically when the character is destroyed.
Not this?
No.
Personally not a big fan of preloading everything. There’s no guarantee roblox will keep it in memory. Just preload it when you’re actually going to use it.
Doing the method I described seems to work without lag/issues. Not 100% sure, but it does seem to download the animation as soon as you load it on the animator.