Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my Music Player not work properly?

It's in a localscript in startergui.

--Script by OpticUniversse in collaboration with Optic Studios
--Help via scriptinghelpers.com was provided by _______

local SoundTable = 
{
    game.Workspace:WaitForChild("316140510"),
    game.Workspace:WaitForChild("438917260"),
    game.Workspace:WaitForChild("467369212"), 
	game.Workspace:WaitForChild("399781334"),
	game.Workspace:WaitForChild("425341748"),
    game.Workspace:WaitForChild("473452993"),
    game.Workspace:WaitForChild("491118865"), 
	game.Workspace:WaitForChild("461736208")
}

while true do
    for i = 1, #SoundTable do
        SoundTable[i]:Play()
        SoundTable[i].Ended:wait()
    end
end

All help will be credited in the script.

1 answer

✓ Accepted answer

Simplification

Let's simplify the script, I would rather just change the SoundId of ONE sound object instead of adding multiple sound objects.

You can use a table to store the IDs of the sounds you want, then change the SoundId to one another in chronological order every time it ends.

Here is the edited script:

local sound = game.Workspace.Sound -- Makes a variable to locate the sound in Workspace. Insert ONLY ONE Sound object in Workspace!!!
local soundTable = {316140510, 438917260, 467369212, 399781334, 425341748, 473452993, 491118865, 461736208} -- A list of IDs.

while true do
	for i = 1, #soundTable do
		sound.SoundId = "rbxassetid://"..soundTable[i] -- Changes to the next SoundId in the table.
		sound:Play() -- Plays the sound.
		sound.Ended:wait() -- Waits for the sound to end.
		wait(3) -- Waits for 3 seconds before the next music plays. (Optional)
	end
	-- The sound will play back the first track if all the tracks are ended.
end

If you have any problems, please leave a comment below. Thank you and I hope this will help you!

2 comments

0

Thanks so much for your help!

0

You're welcome! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.