There are lots of sounds and animations within my game. Animations have a lot of KeyFrame triggers tied to them, so its important that they load quickly. And I really don’t want there to be any delay in sounds when the player starts interacting with the game.
In order to get around the initial loading “Delay” I’ve been using the following method;
function LoadMyAssets() --All this does is loads Sound and Animation. Currently no way of rushing Mesh/OBJ.
local Sounds = CLIENT.RepFirst:WaitForChild("Sounds")
local Animations = CLIENT.RepFirst:WaitForChild("Animations")
local AnimControl = Instance.new("AnimationController")
AnimControl.Parent = CLIENT.RepFirst
local MySound = CLIENT.SNDOBJ:Clone()
MySound.Parent = workspace
MySound.Volume = 0
for _, sound in pairs(Sounds:GetChildren()) do
MySound.SoundId = sound.SoundId
for _, anim in pairs(Animations) do
local AnimLoad = AnimControl:LoadAnimation(anim)
This basically ensures that when it comes to playing the sound or animation, the client has already loaded it, meaning the delay no-longer exists.
Is there any method that is similair to this for images and meshes at all? I keep having delays when new weapons are equipped where the texture/mesh still takes a few moments to load.
If it doesn’t work for meshes, then a hacky way to do it is to place a transparent version of it into the game for a little bit. People used to do that with images by placing ImageLabels onto the screen briefly to load the images. Of course, don’t do this if you don’t have to.
PreloadAsync is much faster than this and is the only way to solve your inquiry, I can assure you that. It also takes your code and flattens it down to a few lines without creating objects.
PreloadAsync preloads these assets for usage; the code provided merely plays and stops them at run time which is a relatively bad/inefficient practice - it could cause a frame spike depending on how many items are being pushed through for one.
To note, you should not be preloading your whole game; only the assets you need players to see or hear immediately upon initialization.