Skip to content

Instantly share code, notes, and snippets.

@lucasmz-dev
Created September 5, 2021 14:43
Show Gist options
  • Save lucasmz-dev/75a225226b26fefd2f1276d03e2ad6f3 to your computer and use it in GitHub Desktop.
Save lucasmz-dev/75a225226b26fefd2f1276d03e2ad6f3 to your computer and use it in GitHub Desktop.
Simple Music Handler
local SoundService = game:GetService("SoundService")
local Sound do
Sound = Instance.new("Sound")
Sound.Name = "Music"
Sound.Parent = SoundService
end
local SongIndex = 1
local Songs = {
"rbxassetid://5807578490",
"rbxassetid://5410086218"
}
local function ChangeSong()
Sound.SoundId = Songs[SongIndex]
if Sound.IsLoaded == false then
Sound.Loaded:Wait()
end
Sound:Play()
SongIndex = SongIndex >= #Songs and 1 or SongIndex + 1
end
ChangeSong()
Sound.Ended:Connect(ChangeSong)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment