Codectionary / Developer documentation / Luau

Sound playback

Play an approved audio asset from a sound instance.

Why use Sound?

Sound provides audio feedback for actions and environments. SoundId identifies the audio asset; whether it plays depends on asset availability, permissions, and runtime audio settings.

Try it in Roblox Studio

In Studio, add a Sound named DoorOpen under a Part named Door and assign it an audio asset you are allowed to use. Put this Script in ServerScriptService.

Syntax

sound:Play()

Examples

Sound playback

Play a configured sound without inventing an asset ID.

local door = workspace:WaitForChild("Door")
local sound = door:WaitForChild("DoorOpen")
assert(sound:IsA("Sound"))
if sound.SoundId ~= "" then
    sound.Volume = 0.5
    sound:Play()
end
  1. The Sound instance and its permitted SoundId are configured in Studio.
  2. Volume changes its playback level; Play begins playback when the asset can be loaded.
  3. The nonempty check avoids calling Play for an unconfigured sound, but it cannot guarantee asset permission or successful loading.

Best practices

  • Use audio assets with the correct ownership and permissions.
  • Keep sound levels comfortable and test on multiple devices.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading