배우기
엔진 클래스
Sound

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.


코드 샘플
음악 재생 파트
local part = Instance.new("Part")
part.Anchored = true
part.Position = Vector3.new(0, 3, 0)
part.BrickColor = BrickColor.new("Bright red")
part.Name = "MusicBox"
part.Parent = workspace
-- 사운드 생성
local sound = Instance.new("Sound", part)
sound.SoundId = "rbxassetid://9120386436"
sound.EmitterSize = 5 -- 방출기 크기를 줄임 (볼륨 감소를 위해)
sound.Looped = true
sound.Parent = part
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part
-- 사운드 재생 / 정지 전환
clickDetector.MouseClick:Connect(function()
if not sound.IsPlaying then
part.BrickColor = BrickColor.new("Bright green")
sound:Play()
else
part.BrickColor = BrickColor.new("Bright red")
sound:Stop()
end
end)

API 참조
속성
AcousticSimulationEnabled
병렬 읽기
기능: LegacySound
Sound.AcousticSimulationEnabled:boolean

AudioContent
숨김
병렬 읽기
기능: LegacySound
Sound.AudioContent:Content

EmitterSize
사용되지 않음

IsLoaded
읽기 전용
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.IsLoaded:boolean
코드 샘플
사운드 로드
local sound = script.Parent.Sound
if not sound.IsLoaded then
sound.Loaded:Wait()
end
print("사운드가 로드되었습니다!")

IsPaused
숨김
읽기 전용
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.IsPaused:boolean
코드 샘플
사운드가 재생 중이고 사운드가 일시 중지됨
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Looped = true
sound.Parent = workspace
if not sound.isLoaded then
sound.Loaded:Wait()
end
sound:Play()
print(sound.IsPlaying, sound.IsPaused) -- true, false
task.wait(2)
sound:Pause()
print(sound.IsPlaying, sound.IsPaused) -- false, true
task.wait(2)
sound:Play()
print(sound.IsPlaying, sound.IsPaused) -- true, false
task.wait(2)
sound:Stop()
print(sound.IsPlaying, sound.IsPaused) -- false, true

IsPlaying
숨김
읽기 전용
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.IsPlaying:boolean
코드 샘플
사운드가 재생 중이고 사운드가 일시 중지됨
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Looped = true
sound.Parent = workspace
if not sound.isLoaded then
sound.Loaded:Wait()
end
sound:Play()
print(sound.IsPlaying, sound.IsPaused) -- true, false
task.wait(2)
sound:Pause()
print(sound.IsPlaying, sound.IsPaused) -- false, true
task.wait(2)
sound:Play()
print(sound.IsPlaying, sound.IsPaused) -- true, false
task.wait(2)
sound:Stop()
print(sound.IsPlaying, sound.IsPaused) -- false, true

isPlaying
사용되지 않음

Looped
병렬 읽기
기능: LegacySound
Sound.Looped:boolean
코드 샘플
주어진 횟수만큼 반복하기
local function loopNTimes(sound, numberOfLoops)
if not sound.IsPlaying then
sound.Looped = true
local connection = nil
connection = sound.DidLoop:Connect(function(_soundId, numOfTimesLooped)
print(numOfTimesLooped)
if numOfTimesLooped >= numberOfLoops then
-- 연결 해제
connection:Disconnect()
-- 소리 중지
sound:Stop()
end
end)
sound:Play()
end
end
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://0"
loopNTimes(sound, 5)

LoopRegion
병렬 읽기
기능: LegacySound
Sound.LoopRegion:NumberRange

MaxDistance
사용되지 않음

MinDistance
사용되지 않음

Pitch
사용되지 않음

PlaybackLoudness
읽기 전용
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.PlaybackLoudness:number
코드 샘플
볼륨 진폭 표시기
-- StarterPlayer > StarterPlayerScripts에 배치할 것
local Players = game:GetService("Players")
-- 로컬 플레이어 PlayerGui를 기다립니다
local LocalPlayer = Players.LocalPlayer
local playerGui = LocalPlayer:WaitForChild("PlayerGui")
-- ScreenGui를 생성합니다
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = playerGui
-- 표시기를 위한 홀더 생성
local frame = Instance.new("Frame")
frame.AnchorPoint = Vector2.new(0.5, 0.5)
frame.Position = UDim2.new(0.5, 0, 0.5, 0)
frame.Size = UDim2.new(0.3, 0, 0.05, 0)
frame.Parent = screenGui
-- 표시기 생성
local bar = Instance.new("Frame")
bar.Position = UDim2.new(0, 0, 0, 0)
bar.Size = UDim2.new(1, 0, 1, 0)
bar.BackgroundColor3 = Color3.new(0, 1, 0)
bar.Parent = frame
-- 사운드 생성
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Looped = true
sound.Parent = screenGui
sound:Play()
-- 최대 볼륨 정의
local maxLoudness = 30
-- 진폭 표시기 애니메이션
while true do
local amplitude = math.clamp(sound.PlaybackLoudness / maxLoudness, 0, 1)
bar.Size = UDim2.new(amplitude, 0, 1, 0)
wait(0.05)
end

PlaybackRegion
병렬 읽기
기능: LegacySound
Sound.PlaybackRegion:NumberRange

PlaybackRegionsEnabled
병렬 읽기
기능: LegacySound
Sound.PlaybackRegionsEnabled:boolean

PlaybackSpeed
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.PlaybackSpeed:number
코드 샘플
사운드 재생 속도
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Looped = true
sound.Parent = workspace
sound:Play()
task.wait(10)
sound.PlaybackSpeed = 3 -- 3배 빨라짐
task.wait(5)
sound.PlaybackSpeed = 0.5 -- 2배 느려짐
task.wait(5)
sound.PlaybackSpeed = 1 -- 기본값

Playing
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.Playing:boolean
코드 샘플
사운드 재생
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Looped = true
sound.Parent = workspace
print("사운드 재생 중")
sound.Playing = true
task.wait(10)
print("사운드 중지")
sound.Playing = false
task.wait(5)
sound.Playing = true
local timePosition = sound.TimePosition
print("재개된 시간 위치: " .. tostring(timePosition)) -- 약 10초

PlayOnRemove
병렬 읽기
기능: LegacySound
Sound.PlayOnRemove:boolean

RollOffMaxDistance
병렬 읽기
기능: LegacySound
Sound.RollOffMaxDistance:number

RollOffMinDistance
병렬 읽기
기능: LegacySound
Sound.RollOffMinDistance:number

RollOffMode
병렬 읽기
기능: LegacySound
Sound.RollOffMode:Enum.RollOffMode

SoundGroup
병렬 읽기
기능: LegacySound
Sound.SoundGroup:SoundGroup

SoundId
병렬 읽기
기능: LegacySound
Sound.SoundId:ContentId

TimeLength
읽기 전용
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.TimeLength:number
코드 샘플
특정 시간 동안 사운드 재생하기
local function playForDuration(sound, duration)
if not sound.IsLoaded then
sound.Loaded:wait()
end
local speed = sound.TimeLength / duration
sound.PlaybackSpeed = speed
sound:Play()
end
local sound = script.Parent
playForDuration(sound, 5)

TimePosition
복제되지 않음
병렬 읽기
기능: LegacySound
Sound.TimePosition:number
코드 샘플
사운드 시간 위치
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120386436"
sound.Parent = workspace
sound.TimePosition = 30
sound:Play()
task.wait(5)
sound.TimePosition = 100
task.wait(5)
sound.TimePosition = 0

Volume
병렬 읽기
기능: LegacySound
Sound.Volume:number

메서드
Pause
기능: LegacySound
Sound:Pause():()
반환
()
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

pause
사용되지 않음

Play
기능: LegacySound
Sound:Play():()
반환
()
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

play
사용되지 않음

Resume
기능: LegacySound
Sound:Resume():()
반환
()
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

Stop
기능: LegacySound
Sound:Stop():()
반환
()
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

stop
사용되지 않음

이벤트
DidLoop
기능: LegacySound
Sound.DidLoop(
soundId:string, numOfTimesLooped:number
매개 변수
soundId:string
numOfTimesLooped:number
코드 샘플
주어진 횟수만큼 반복하기
local function loopNTimes(sound, numberOfLoops)
if not sound.IsPlaying then
sound.Looped = true
local connection = nil
connection = sound.DidLoop:Connect(function(_soundId, numOfTimesLooped)
print(numOfTimesLooped)
if numOfTimesLooped >= numberOfLoops then
-- 연결 해제
connection:Disconnect()
-- 소리 중지
sound:Stop()
end
end)
sound:Play()
end
end
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://0"
loopNTimes(sound, 5)

Ended
기능: LegacySound
Sound.Ended(soundId:string):RBXScriptSignal
매개 변수
soundId:string

Loaded
기능: LegacySound
Sound.Loaded(soundId:string):RBXScriptSignal
매개 변수
soundId:string
코드 샘플
사운드 로드
local sound = script.Parent.Sound
if not sound.IsLoaded then
sound.Loaded:Wait()
end
print("사운드가 로드되었습니다!")

Paused
기능: LegacySound
Sound.Paused(soundId:string):RBXScriptSignal
매개 변수
soundId:string
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

Played
기능: LegacySound
Sound.Played(soundId:string):RBXScriptSignal
매개 변수
soundId:string
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

Resumed
기능: LegacySound
Sound.Resumed(soundId:string):RBXScriptSignal
매개 변수
soundId:string
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

Stopped
기능: LegacySound
Sound.Stopped(soundId:string):RBXScriptSignal
매개 변수
soundId:string
코드 샘플
사운드 함수
-- 소리 생성
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://9120386436"
if not sound.IsLoaded then
sound.Loaded:Wait()
end
-- 이벤트 수신
sound.Played:Connect(function(_soundId)
print("Sound.Played 이벤트")
end)
sound.Paused:Connect(function(_soundId)
print("Sound.Paused 이벤트")
end)
sound.Resumed:Connect(function(_soundId)
print("Sound.Resumed 이벤트")
end)
sound.Stopped:Connect(function(_soundId)
print("Sound.Stopped 이벤트")
end)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0
task.wait(10)
sound:Pause()
print("일시 정지", sound.Playing, sound.TimePosition) -- 일시 정지 false 10
task.wait(3)
sound:Resume()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 10
task.wait(3)
sound:Stop()
print("정지", sound.Playing, sound.TimePosition) -- 정지 false 0
task.wait(3)
sound:Play()
print("재생", sound.Playing, sound.TimePosition) -- 재생 true 0

©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.