I have two scripts, one is used for playing music, one is used for changing the map in the game, what I would like to know is how to make it so music will only play on the map that it's made to play on? I'm putting the music script in the map models them selves, when the map is pulled up it'll start the music, however when the map changes, them usic from the one that was just up stays. Any help is appreciated
Music Script:
ID = '307904550'-- put the id of the song here Looped = false -- Set to false if you want non-looped music. Music=Instance.new("Sound" ,Workspace) Music.Name = "Music" if Looped == true then Music.Looped = true end Music.SoundId = "http://roblox.com/asset/?id="..ID.."" Music:Play()
Map Change Script:
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
Just create a sound and put it in the model/map, set its properties Then at the line 6 of map change script, put
mapCopy.Music:Play() -- Assuming that u put the song inside of the map and u named it Music