Created
September 5, 2021 14:43
-
-
Save lucasmz-dev/75a225226b26fefd2f1276d03e2ad6f3 to your computer and use it in GitHub Desktop.
Simple Music Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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