Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can I somehow combine these to make it so music stays specific with it's map?

Asked by 4 years ago

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

1 answer

Log in to vote
0
Answered by
St_vnC 330 Moderation Voter
4 years ago

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
0
It didn't work, it broke the whole game actually Cynical_Potatoe 5 — 4y
0
Lol sorry St_vnC 330 — 4y
0
Try adding The music script from line 6 then St_vnC 330 — 4y
0
It starts a whole new function, it would disrupt the flow of the script and break it. Thanks for the suggestions anyway Cynical_Potatoe 5 — 4y
Ad

Answer this question