Sound
Defined in: server/api.d.ts:2022
Replicated positional sound source that every nearby client plays through the game’s own mixer.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Sound(
id):Sound
Defined in: server/api.d.ts:2027
Creates a script wrapper for an existing sound with this ID; use Sound.create() to place one.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Sound
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy():
void
Defined in: server/api.d.ts:2073
Stops this sound and removes it from every client.
Returns
Section titled “Returns”void
setEnabled()
Section titled “setEnabled()”setEnabled(
enabled):void
Defined in: server/api.d.ts:2115
Sets whether this sound is currently playing. Re-enabling restarts it.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
True to play, false to fall silent without destroying the sound.
Returns
Section titled “Returns”void
setInnerRadius()
Section titled “setInnerRadius()”setInnerRadius(
innerRadius):void
Defined in: server/api.d.ts:2103
Sets the distance inside which no falloff is applied; the sound restarts.
Parameters
Section titled “Parameters”innerRadius
Section titled “innerRadius”number
Distance in world units within which the sound plays at full volume; must be smaller than the radius.
Returns
Section titled “Returns”void
setLoop()
Section titled “setLoop()”setLoop(
loop):void
Defined in: server/api.d.ts:2109
Sets whether this sound repeats.
Parameters
Section titled “Parameters”boolean
True to repeat forever, false to play the wave once.
Returns
Section titled “Returns”void
setPitch()
Section titled “setPitch()”setPitch(
pitch):void
Defined in: server/api.d.ts:2091
Sets the playback rate; the sound restarts, because the rate is fixed when the voice is built.
Parameters
Section titled “Parameters”number
Playback rate multiplier from 0.25 to 4, where 1 is the recorded pitch.
Returns
Section titled “Returns”void
setRadius()
Section titled “setRadius()”setRadius(
radius):void
Defined in: server/api.d.ts:2097
Sets how far this sound carries; the sound restarts.
Parameters
Section titled “Parameters”radius
Section titled “radius”number
Distance in world units beyond which the sound is inaudible; must be greater than 0 and at most 500.
Returns
Section titled “Returns”void
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:4154
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: server/api.d.ts:4160
Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVolume()
Section titled “setVolume()”setVolume(
volume):void
Defined in: server/api.d.ts:2085
Sets how loud this sound is, without restarting it.
Parameters
Section titled “Parameters”volume
Section titled “volume”number
Linear gain from 0 to 2, where 1 is the recorded level.
Returns
Section titled “Returns”void
setWave()
Section titled “setWave()”setWave(
wave):void
Defined in: server/api.d.ts:2079
Sets which wave this sound plays; the sound restarts on every client that has it.
Parameters
Section titled “Parameters”string
Name of a wave in the game’s sound archives, such as “Ambienty/ambi_noc1”.
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:2068
Returns a readable representation of this sound.
Returns
Section titled “Returns”string
The sound’s ID, wave and reach formatted for logging or debugging.
Inherited from
Section titled “Inherited from”create()
Section titled “create()”
staticcreate(x,y,z,wave,radius?,volume?,virtualWorld?):Sound
Defined in: server/api.d.ts:2128
Places a looping sound that plays until it is destroyed. A wave the client does not have is silent there.
Parameters
Section titled “Parameters”number
World-space X coordinate of the sound.
number
World-space Y coordinate of the sound.
number
World-space Z coordinate of the sound.
string
Name of a wave in the game’s sound archives, such as “Ambienty/ambi_noc1”.
radius?
Section titled “radius?”number
Optional distance in world units beyond which the sound is inaudible; defaults to 25.
volume?
Section titled “volume?”number
Optional linear gain from 0 to 2; defaults to 1.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual-world ID used for visibility filtering.
Returns
Section titled “Returns”Sound
The newly created sound handle.
play()
Section titled “play()”
staticplay(x,y,z,wave,radius?,volume?,pitch?):void
Defined in: server/api.d.ts:2140
Plays a wave once at a position on every client. Nothing is replicated, so it cannot be stopped or moved.
Parameters
Section titled “Parameters”number
World-space X coordinate to play at.
number
World-space Y coordinate to play at.
number
World-space Z coordinate to play at.
string
Name of a wave in the game’s sound archives.
radius?
Section titled “radius?”number
Optional distance in world units beyond which it is inaudible; defaults to 25.
volume?
Section titled “volume?”number
Optional linear gain from 0 to 2; defaults to 1.
pitch?
Section titled “pitch?”number
Optional playback rate multiplier from 0.25 to 4; defaults to 1.
Returns
Section titled “Returns”void
playForPlayer()
Section titled “playForPlayer()”
staticplayForPlayer(player,x,y,z,wave,radius?,volume?,pitch?):void
Defined in: server/api.d.ts:2153
Plays a wave once at a position, for one player only.
Parameters
Section titled “Parameters”player
Section titled “player”The player who should hear it.
number
World-space X coordinate to play at.
number
World-space Y coordinate to play at.
number
World-space Z coordinate to play at.
string
Name of a wave in the game’s sound archives.
radius?
Section titled “radius?”number
Optional distance in world units beyond which it is inaudible; defaults to 25.
volume?
Section titled “volume?”number
Optional linear gain from 0 to 2; defaults to 1.
pitch?
Section titled “pitch?”number
Optional playback rate multiplier from 0.25 to 4; defaults to 1.
Returns
Section titled “Returns”void
stopAll()
Section titled “stopAll()”
staticstopAll():number
Defined in: server/api.d.ts:2159
Destroys every placed sound. One-shots already on their way are unaffected.
Returns
Section titled “Returns”number
The number of sounds that were destroyed.
Properties
Section titled “Properties”enabled
Section titled “enabled”
readonlyenabled:boolean
Defined in: server/api.d.ts:2062
Whether the sound is currently playing.
readonlyid:number
Defined in: server/api.d.ts:4122
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”innerRadius
Section titled “innerRadius”
readonlyinnerRadius:number
Defined in: server/api.d.ts:2052
Distance in world units within which the sound plays at full volume.
readonlyloop:boolean
Defined in: server/api.d.ts:2057
Whether the sound repeats.
readonlypitch:number
Defined in: server/api.d.ts:2042
Playback rate multiplier, where 1 is the recorded pitch.
position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:4132
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”radius
Section titled “radius”
readonlyradius:number
Defined in: server/api.d.ts:2047
Distance in world units beyond which the sound is inaudible.
rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: server/api.d.ts:4137
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”
readonlystate:StateBag
Defined in: server/api.d.ts:4142
Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.
Inherited from
Section titled “Inherited from”virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:4127
Current virtual-world identifier.
Inherited from
Section titled “Inherited from”volume
Section titled “volume”
readonlyvolume:number
Defined in: server/api.d.ts:2037
Linear gain, where 1 is the recorded level.
readonlywave:string
Defined in: server/api.d.ts:2032
Name of the wave this sound plays.
