📁 1. Adding Sounds
- Sounds can be inserted into parts (e.g., a door),
SoundService, or Workspace.
- You can do this in the Explorer or with code:
▶️ 1. Basic Sound Controls
Play a sound:
lua
CopyEdit
sound:Play()
Stop a sound:
lua
CopyEdit
sound:Stop()
Pause a sound (only works in some situations):
lua
CopyEdit
sound:Pause()
🎚️ 3. Useful Sound Properties
| Property |
Description |
SoundId |
The asset ID of the sound ("rbxassetid://123456789") |
Volume |
0 to 1 (default 0.5 or 1) |
Pitch |
Speed/pitch of sound. Default is 1 |
Looped |
true = loops until stopped |
Playing |
Boolean: is the sound currently playing? |
TimePosition |
Where in the sound (in seconds) it's currently playing |
PlayOnRemove |
Plays the sound when the object is destroyed |
🧠 5. Examples
Play a sound when a part is touched:
lua
CopyEdit
local part = script.Parent
local sound = part:WaitForChild("Sound")
part.Touched:Connect(function()
sound:Play()
end)
Play background music in SoundService:
lua
CopyEdit
local bgMusic = Instance.new("Sound")
bgMusic.SoundId = "rbxassetid://123456789"
bgMusic.Looped = true
bgMusic.Volume = 0.5
bgMusic.Parent = game:GetService("SoundService")
bgMusic:Play()