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

Loaded

The Sound.Loaded event fires when the /Sound is loaded.

Note this event will only fire at the time the sound is loaded. This means if it is listened for when the sound is already loaded it will not return. Therefore it is recommended to check Sound/IsLoaded prior to connecting to this event.

Parameters

Name Type Default Description

The Sound/SoundId of the Sound that loaded.


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