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

Using the Disaster Kit V2, how can I make maps have different music?

So I'm playing around with the Disaster Kit V2 and I made a map rotation system, and I want to make every map have a different background music, but when the map changes, the song keeps playing. How can I make it so specific music only plays on it's specific map?

Here's the script for the map changing if it helps:

function regenStructures()
	workspace.Structures:ClearAllChildren()
	local maps = game.ServerStorage.Clones.Maps:GetChildren()
	local mapCopy = maps[math.random(1, #maps)]:Clone()
	mapCopy.Parent = workspace.Structures
	mapCopy:MakeJoints()
end

1 comment

0

well... the easiest way is to create a part where the players spawn and have a script inside of it and when the players touches it, the music plays. Or you can make a script that whenever a map changes or the game starts, the music starts playing and afterwards, it gets destroyed and so on.

1 answer

Here's my concept, why not make a folder where you store your audios?

So if you have audio sound stored in your folder, it should be like this. (make sure sounds are named)

local sound = Instance.new("Sound", game.Workspace)
local bm = --location of the folder
local st = bm.--(sound in folder you want to play)
local en = bm.--(sound you want to stop)

function regenStructures()
	workspace.Structures:ClearAllChildren()
	local maps = game.ServerStorage.Clones.Maps:GetChildren()
	local mapCopy = maps[math.random(1, #maps)]:Clone()
	mapCopy.Parent = workspace.Structures
	mapCopy:MakeJoints()
wait(1)
	en.--(audio in the folder currently playing).Sound:Stop()
	sound.Looped = true
	st.--(audio that you want to play next).Sound:Play()
end

If you have any errors or questions about this, feel free to ask, and I might edit this again.

3 comments

0

I havent used it yet, I'll work on implementing it momentarily but before I do, this should let me assign specific songs for specific maps?

0

It should, that's why I insist making a folder filled with sounds (uniquename); ones that you want to keep in your game and not forget.

0

It didn't work unfortunetly, I'll create another question with clearer questions

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