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

Works on studio but not in-game, what's the problem?

The script is in a folder called "AudioController" and the music IDs are in another folder called "Songs"

local sound = Instance.new("Sound")
sound.Parent = game.Soundscape
sound.Name = "CoolAudio"

local number = 1
local songs = script.Parent.Songs:GetChildren()

local currentsong = 1
local nowplaying = 0

for i=1,#songs do
	songs[i].Name = tostring(number)
	number = number + 1
end

function cycle()
	local song = script.Parent.Songs:FindFirstChild(tostring(currentsong))
	if song == nil then
		currentsong = 1
		wait()
		cycle()
	else
		nowplaying = song.Value
		sound.SoundId = "rbxassetid://" .. tostring(song.Value)
		sound:Play()
		wait(sound.TimeLength)
		currentsong = currentsong + 1
		sound:Stop()
		cycle()
	end
end

cycle()

1 answer

✓ Accepted answer

In order for your song to be heard ingame, it has to be in the Workspace, Soundscape is like a storage place, not a song-playing service.

2 comments

0

The audio now plays in-game though it stops as soon as you actually spawn.

0

Try and redo the script, this time make the sound play and exist in the workspace, and make is more simple, there are more less complicated and efficient ways to play sound like this.

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