Zythronis

DOORS MUSIC PLAYER

Oct 26th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.25 KB | Gaming | 0 0
  1. local Options = getgenv().Linoria.Options
  2. local Toggles = getgenv().Linoria.Toggles
  3.  
  4. local Addon = {
  5.     Name = "MusicPlayerAddon",  -- Addon Name
  6.     Title = "Music Player",      -- Title of the GroupBox
  7.     Description = "Listen to your favorite tunes!",
  8.     Game = {
  9.         "doors/doors",            -- Targeted games
  10.         "doors/lobby"
  11.     },
  12.  
  13.     Elements = {
  14.         {
  15.             Type = "Toggle",  -- Toggle for built-in song
  16.             Name = "ToggleRainingTacos",
  17.             Arguments = {
  18.                 Text = 'Play/Stop "It's Raining Tacos"',
  19.                Tooltip = 'Click to play or stop the song.',
  20.                
  21.                Callback = function(value)
  22.                    local player = game.Players.LocalPlayer
  23.                    local sounds = game:GetService("SoundService")
  24.  
  25.                    -- Create a BoolValue to track if the song is playing
  26.                    if not player:FindFirstChild("songplaying") then
  27.                        local songplay = Instance.new("BoolValue")
  28.                        songplay.Name = "songplaying"
  29.                        songplay.Parent = player
  30.                    end
  31.                    
  32.                    -- Check for existing sound instance
  33.                    local tacosSound = sounds:FindFirstChild("RainingTacos")
  34.                    if not tacosSound then
  35.                        tacosSound = Instance.new("Sound")
  36.                        tacosSound.Name = "RainingTacos"
  37.                        tacosSound.SoundId = "rbxassetid://142295308"  -- ID for "It's Raining Tacos"
  38.                        tacosSound.Looped = true
  39.                        tacosSound.Volume = _G.SongVolume or 1
  40.                        tacosSound.Parent = sounds
  41.                    end
  42.  
  43.                    -- Play or stop the song based on the toggle value
  44.                    if value then
  45.                        tacosSound:Play()
  46.                        player.songplaying.Value = true
  47.                        print('"It's Raining Tacos" is now playing!')
  48.                    else
  49.                        tacosSound:Stop()
  50.                        player.songplaying.Value = false
  51.                        print('"It's Raining Tacos" has been stopped.')
  52.                    end
  53.                end
  54.            }
  55.        },
  56.  
  57.        {
  58.            Type = "Input",  -- Input for custom song ID
  59.            Name = "CustomSongId",
  60.            Arguments = {
  61.                Default = '',
  62.                Numeric = true,
  63.                Finished = true,
  64.                ClearTextOnFocus = true,
  65.  
  66.                Text = 'Enter Custom Song ID',
  67.                Tooltip = 'Input a valid Roblox sound ID',
  68.  
  69.                Placeholder = 'Enter a sound ID here',
  70.  
  71.                Callback = function(value)
  72.                    _G.customSongId = tonumber(value)
  73.                    print("Custom song ID set to: " .. tostring(_G.customSongId))
  74.                end
  75.            }
  76.        },
  77.  
  78.        {
  79.            Type = "Button",  -- Button to play the custom song
  80.            Name = "PlayCustomSong",
  81.            Arguments = {
  82.                Text = 'Play Custom Song',
  83.                Tooltip = 'Plays the song using the provided ID.',
  84.                
  85.                Func = function()
  86.                    local sounds = game:GetService("SoundService")
  87.                    local customSongSound = sounds:FindFirstChild("CustomSong")
  88.                    
  89.                    if not customSongSound then
  90.                        customSongSound = Instance.new("Sound")
  91.                        customSongSound.Name = "CustomSong"
  92.                        customSongSound.Looped = true
  93.                        customSongSound.Volume = _G.SongVolume or 1
  94.                        customSongSound.Parent = sounds
  95.                    end
  96.  
  97.                    -- Check for a valid custom song ID
  98.                    if _G.customSongId then
  99.                        customSongSound.SoundId = "rbxassetid://" .. tostring(_G.customSongId)
  100.                        customSongSound:Play()
  101.                        print("Playing custom song with ID: " .. tostring(_G.customSongId))
  102.                    else
  103.                        print("Please enter a valid song ID first.")
  104.                    end
  105.                end
  106.            }
  107.        },
  108.  
  109.        {
  110.            Type = "Button",  -- Button to stop the custom song
  111.            Name = "StopCustomSong",
  112.            Arguments = {
  113.                Text = 'Stop Custom Song',
  114.                Tooltip = 'Stops the currently playing custom song.',
  115.                
  116.                Func = function()
  117.                    local sounds = game:GetService("SoundService")
  118.                    local customSongSound = sounds:FindFirstChild("CustomSong")
  119.                    
  120.                    if customSongSound and customSongSound.IsPlaying then
  121.                        customSongSound:Stop()
  122.                        print("Custom song has been stopped.")
  123.                    else
  124.                        print("No custom song is currently playing.")
  125.                    end
  126.                end
  127.            }
  128.        },
  129.  
  130.        {
  131.            Type = "Slider",  -- Slider for volume control
  132.            Name = "VolumeOfSong",
  133.            Arguments = {
  134.                Text = 'Volume',
  135.                Tooltip = 'Adjust the volume for the songs.',
  136.                Default = 1,
  137.                Max = 2,
  138.                Min = 0,
  139.                Rounding = 1,
  140.  
  141.                Callback = function(value)
  142.                    _G.SongVolume = tonumber(value)
  143.                    local sounds = game:GetService("SoundService")
  144.  
  145.                    -- Update the volume of currently playing sounds
  146.                    local tacosSound = sounds:FindFirstChild("RainingTacos")
  147.                    if tacosSound then
  148.                        tacosSound.Volume = _G.SongVolume
  149.                    end
  150.                    
  151.                    local customSongSound = sounds:FindFirstChild("CustomSong")
  152.                    if customSongSound then
  153.                        customSongSound.Volume = _G.SongVolume
  154.                    end
  155.                    print("Volume set to: " .. tostring(_G.SongVolume))
  156.                end
  157.            }
  158.        }
  159.    }
  160. }
  161.  
  162. return Addon
Advertisement
Add Comment
Please, Sign In to add comment