PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

IsLoaded

Sound

bool

This property will be true when the Sound has loaded loaded from Roblox servers and is ready to play.

In Roblox, audio files are not stored in games themselves but hosted on the Roblox servers and referenced by the Sound/SoundId property. This means that they need to be downloaded to a client’s device before they can be played. This can take a while depending on the user’s internet connection, the length of the sound and the number of other objects that need to be loaded.

Developers can use the Sound/IsLoaded property and the Sound/Loaded event if they wish to verify a sound has loaded before playing it.


Code Samples


Load Sound

This simple function will verify a Sound has loaded by checking the Sound.IsLoaded property. If Sound.IsLoaded is false it will wait for the Loaded event before resuming.

It is important to check Sound.IsLoaded before connecting to the Sound.Loaded event, as if the sound has already loaded the Sound.Loaded event will not fire and the function will yield indefinitely.

local function loadSound(sound)
	-- has the sound already loaded?
	if not sound.IsLoaded then 
		-- if not, wait until it has been
		sound.Loaded:wait()
	end
end