Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Reason 2 Die music addon
- Enhancing your R2DA experience since 2022.
- Version: PROTOTYPE 1.0.0
- Todo:
- Victory music
- Start ambience of Dead Vacation
- Buried Alive exclusive soundtrack
- Boss music
- Bug fixes!
- --]]
- math.randomseed(os.time())
- local plr = game.Players.LocalPlayer
- local pgui = plr.PlayerGui
- local chat = pgui:WaitForChild("Chat")
- local musicScript = chat.Code:FindFirstChild("Music")
- local normalSound = musicScript:WaitForChild("Sound")
- local serverSettings = workspace:FindFirstChild("Settings")
- local currentMap = serverSettings.CurrentMap
- local reps = game:GetService("ReplicatedStorage")
- local inmenu = false
- local loading = false
- local champion = false
- local victory = false
- local musicList = { -- Preload
- ["Victory"] = getsynasset("Victory.mp3"),
- ["Menu"] = getsynasset("Menu.mp3"),
- ["Loading"] = getsynasset("Loading.mp3"),
- ["Universal1"] = getsynasset("Universal1.mp3"),
- ["Universal2"] = getsynasset("Universal2.mp3"),
- ["Universal3"] = getsynasset("Universal3.mp3"),
- ["Universal4"] = getsynasset("LateGame1.mp3"),
- ["Universal5"] = getsynasset("LateGame2.mp3"),
- ["BuriedAlive"] = getsynasset("BuriedAlive.mp3"),
- ["DeadVacationStart"] = getsynasset("DeadVacationStart.mp3"),
- ["Champion"] = getsynasset("Champion.mp3"),
- ["ChronoQuest"] = getsynasset("ChronoQuest.mp3"),
- ["ChronoBoss"] = getsynasset("ChronoBoss.mp3"),
- ["CherryQuest"] = getsynasset("CherryQuest.mp3"),
- ["CherryBoss"] = getsynasset("CherryBoss.mp3"),
- ["CasinoHall"] = getsynasset("CasinoHall.mp3"),
- ["Jackpot"] = getsynasset("Jackpot.mp3"), -- Casino hall boss
- ["DuckyQuest"] = getsynasset("DuckyQuest.mp3")
- }
- local playingMusic = false
- local lastUniversal = 0
- local currentMusic = Instance.new("Sound", reps)
- currentMusic.Name = "CurrentMusic"
- currentMusic.Volume = normalSound.Volume
- local menuMusic = Instance.new("Sound", reps)
- menuMusic.Name = "MenuMusic"
- menuMusic.Volume = 1.5
- menuMusic.Looped = true
- menuMusic.SoundId = musicList["Menu"]
- local loadingMusic = Instance.new("Sound", reps)
- loadingMusic.Name = "LoadingMusic"
- loadingMusic.Volume = 1.5
- loadingMusic.SoundId = musicList["Loading"]
- local function stopMusic(id)
- if id == "Menu" then
- menuMusic:Stop()
- currentMusic.Volume = 1.5
- elseif id == "Loading" then
- loadingMusic:Stop()
- currentMusic.Volume = 1
- else
- currentMusic:Stop()
- playingMusic = false
- end
- end
- local function playMusic(id)
- print("got play request " ..id)
- if id == "Menu" then
- currentMusic.Volume = 0
- menuMusic:Play()
- elseif id == "Loading" then
- currentMusic.Volume = 0
- loadingMusic:Play()
- else
- stopMusic()
- if not inmenu and not loading then
- currentMusic.SoundId = musicList[id]
- currentMusic.Volume = .75
- currentMusic:Play()
- playingMusic = true
- local cn; cn = currentMusic.Changed:Connect(function()
- if currentMusic.Playing == false then
- cn:Disconnect()
- playingMusic = false
- end
- end)
- end
- end
- end
- local cn1; cn1 = pgui.ChildAdded:Connect(function(obj)
- if obj.Name == "Menu" then
- -- play menu music!!
- inmenu = true
- playMusic("Menu")
- elseif obj.Name == "LoadMap" then
- -- play loading music!!
- loading = true
- playMusic("Loading")
- end
- end)
- local cn2; cn2 = pgui.ChildRemoved:Connect(function(obj)
- if obj.Name == "Menu" then
- -- stop menu music!!
- stopMusic("Menu")
- inmenu = false
- elseif obj.Name == "LoadMap" then
- -- stop loading music!!
- stopMusic("Loading")
- loading = false
- end
- end)
- local cn3; cn3 = normalSound.Changed:Connect(function()
- if inmenu == false and loading == false then
- currentMusic.Volume = .75
- end
- if (normalSound.SoundId == "4596210702" and normalSound.Playing == true) or (normalSound.SoundId == "rbxassetid://4596210702" and normalSound.Playing == true) then -- Champion!!
- -- play champion music
- champion = true
- playMusic("Champion")
- else
- if champion == true then
- stopMusic()
- end
- champion = false
- end
- end)
- -- initialization
- if pgui:FindFirstChild("Menu") then
- inmenu = true
- playMusic("Menu")
- end
- if pgui:FindFirstChild("LoadMap") then
- loading = true
- -- doesn't play music to avoid complication since loading screen is usually fast
- end
- print("R2DA music addon loaded")
- while true do -- each attempt to do music
- if playingMusic == false and champion == false then
- -- can play music
- if currentMap.Gamemode.Value ~= "QUEST" and currentMap.Gamemode.Value ~= "BOSS" then
- -- a normal gamemode
- local rng
- repeat
- rng = math.random(1, 5)
- wait(.03)
- until rng ~= lastUniversal
- lastUniversal = rng
- elseif currentMap.Gamemode.Value == "QUEST" then
- if currentMap.Value == "QuestChronos" then
- -- Chrono quest
- playMusic("ChronoQuest")
- elseif currentMap.Value == "CasinoHalls" then
- -- Casino Hall
- playMusic("CasinoHall")
- elseif currentMap.Value == "QCherry" then
- -- Cherry quest
- playMusic("CherryQuest")
- end
- elseif currentMap.Gamemode.Value == "BOSS" then -- boss music not yet properly implemented
- if currentMap.Value == "BossChronos" then
- -- Chrono boss
- playMusic("ChronoBoss")
- elseif currentMap.Value == "BossCherrycake" then
- -- Cherry boss
- playMusic("CherryBoss")
- else
- -- Jackpot
- playMusic("Jackpot")
- end
- end
- end
- repeat wait(5)
- until playingMusic == false
- if currentMap.Gamemode.Value == "QUEST" or currentMusic.Gamemode.Value == "BOSS" then
- wait(5)
- else
- wait(30)
- end
- end
Advertisement
RAW Paste Data
Copied
Advertisement