-
Notifications
You must be signed in to change notification settings - Fork 5
Audio Source Component
Berke edited this page Jun 23, 2026
·
1 revision
The AudioSource component controls 3D spatial audio playback and sound properties.
audio.isValidReturns whether the component is still valid.
booleanaudio.nameReturns the internal name of the audio source.
stringaudio.soundIndexGets or sets the currently assigned sound.
numberaudio.soundIndex = 2audio.pitchControls playback pitch.
numberaudio.pitch = 1.2audio.gainControls volume (gain).
numberaudio.gain = 0.5audio.loopingEnables or disables looping playback.
booleanaudio.playOnStartIf true, sound plays automatically when the scene starts.
booleanaudio.referenceDistanceDistance at which the sound starts attenuating.
numberaudio.maxDistanceMaximum distance the sound can be heard.
numberaudio.rollOffFactorControls how quickly sound attenuates with distance.
numberaudio.innerConeAngleInner angle of directional sound cone.
numberaudio.outerConeAngleOuter angle of directional sound cone.
numberaudio.outerGainVolume outside the outer cone.
numberaudio:play()Plays the assigned sound.
nilaudio:setSourcePosition(position)Sets the world position of the audio source.
| Name | Type | Description |
|---|---|---|
| position | Vector3 | World position of sound source |
nillocal audio = entity.audioSource
audio.gain = 0.8
audio.pitch = 1.1
audio.looping = true
audio:play()