When I click a song, it plays. When i try to click multiple songs it plays the song but the script doesn't work correctly and deletes the previous song before stopping it. Here is the script!:
----------------------------------------------- ----------------------------------------------- local player = script.Parent.Parent.Parent.Parent local M = script.Parent local listbkg = M.ListBkg local stopp = M.StopPic local stop = M.Stop local repb = M.Repeat local repp = M.RepeatPic local musicl = M.MusicList local next = M.Next local less = M.Less local more = M.More local drag = M.Dragger local dragtext = M.DragText local musiclist = {} local musicmodel = script.Parent.Parent.Music local music = musicmodel:children() for i,v in pairs(music) do v.Looped = false v.PlayOnRemove = false table.insert(musiclist,v:clone()) end musicmodel:remove() local musiclistbuttons = {} for i,v in pairs(musiclist) do local ng = Instance.new("TextButton",M) ng.Position = UDim2.new(0, 0, 0, 20) + UDim2.new(0,0,0,13*i) ng.Size = UDim2.new(0, 200, 0, 13) ng.BackgroundTransparency = 1 ng.BackgroundColor3 = Color3.new(0/255,0/255,0/255) ng.BorderColor3 = Color3.new(255/255,255/255,255/255) ng.TextColor3 = Color3.new(255/255,255/255,255/255) ng.Font = "ArialBold" ng.FontSize = "Size10" ng.Visible = false ng.Text = v.Name ng.Name = v.Name table.insert(musiclistbuttons,i,ng) ng.MouseButton1Click:connect(function() if ng.BackgroundTransparency == 1 then changesong(musiclist[i]) end end) end listbkg.Size = UDim2.new(0, 120, 0, 20) + UDim2.new(0,0,0,13*#musiclistbuttons) ----------------------------------------------- ----------------------------------------------- local currentsong = musiclist[1]:clone() local Mgui = Instance.new("BillboardGui") local framegui = Instance.new("Frame") local textlabelgui = Instance.new("TextLabel") if player.Character ~= nil then Mgui.Parent = player.Character framegui.Parent = Mgui Mgui.AlwaysOnTop = true Mgui.StudsOffset = Vector3.new(0, 2, 0) textlabelgui.Parent = framegui if player.Character.Head ~= nil then Mgui.Adornee = player.Character.Head Mgui.Size = UDim2.new(0, 200, 0, 200) framegui.Size = UDim2.new(0, 200, 0, 200) framegui.BackgroundTransparency = 1 textlabelgui.BackgroundTransparency = 1 textlabelgui.TextColor3 = Color3.new(255/255,255/255,255/255) textlabelgui.Size = UDim2.new(0, 200, 0, 200) textlabelgui.Text = "(" .. player.Name .. ") is listening to: Derezzed - Daft Punk" textlabelgui.TextStrokeTransparency = 0 end end local rep = false local open = false local playing = true local beingdragged = false local X = M.Position.X.Offset local Y = M.Position.Y.Offset local XS = M.Position.X.Scale local YS = M.Position.Y.Scale --player.CharacterAdded:wait() drag.MouseButton1Down:connect(function(mx,my) beingdragged = true X = M.Position.X.Offset Y = M.Position.Y.Offset XS = M.Position.X.Scale YS = M.Position.Y.Scale DposX=mx-X DposY=my-Y end) drag.MouseMoved:connect(function(mx,my) if beingdragged then print("Moving") M.Position=UDim2.new(XS,mx - DposX,YS,my - DposY) if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end end end) drag.MouseButton1Up:connect(function() beingdragged = false print("Mouse going up") if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end end) drag.MouseLeave:connect(function() beingdragged = false dragtext.Visible = false print("Mouse left") if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end end) drag.MouseEnter:connect(function() dragtext.Visible = true end) function checkforstop(song) while currentsong.IsPlaying do wait(1) end end function playsong() checkforstop(currentsong) print("Song Stopped") if playing then if rep then currentsong:play() playsong(currentsong) else for i,v in pairs(musiclist) do if currentsong.Name == v.Name then if i == #musiclist then changesong(musiclist[1]) else if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end changesong(musiclist[i+1]) end end end end end end function changesong(song) if playing == true then for i,v in pairs(musiclistbuttons) do if song.Name ~= v.Name then v.BackgroundTransparency = 1 if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end else v.BackgroundTransparency = 0 end end currentsong:stop() wait(0.1) currentsong:remove() print("Successfully Removed the last song") currentsong = song:clone() textlabelgui.Text = "(" .. player.Name .. ") is listening to: " .. currentsong.Name textlabelgui.TextStrokeTransparency = 0 currentsong.Parent = M currentsong:play() stopp.Style = "ChatRed" stop.Text = "Stop" print("Changed Song") playsong(currentsong) elseif playing == false then for i,v in pairs(musiclistbuttons) do if song.Name ~= v.Name then v.BackgroundTransparency = 1 else v.BackgroundTransparency = 0 end end stopp.Style = "ChatGreen" stop.Text = "Play" wait(0.1) currentsong:remove() print("Successfully Removed the last song") currentsong = song:clone() currentsong.Parent = M playsong(currentsong) print("Ready to play song") textlabelgui.Text = "(" .. player.Name .. ") is listening to: " .. currentsong.Name .. " [PAUSED]" textlabelgui.TextStrokeTransparency = 0 end end stop.MouseButton1Click:connect(function() if playing == true then playing = false stopp.Style = "ChatGreen" stop.Text = "Play" textlabelgui.Text = "(" .. player.Name .. ") is listening to: " .. currentsong.Name .. " [PAUSED]" textlabelgui.TextStrokeTransparency = 0 currentsong:stop() print("Stopped Song") else stopp.Style = "ChatRed" if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end stop.Text = "Stop" playing = true currentsong:play() textlabelgui.Text = "(" .. player.Name .. ") is listening to: " .. currentsong.Name textlabelgui.TextStrokeTransparency = 0 print("Playing Song") playsong(currentsong) end end) musicl.MouseButton1Click:connect(function() for _,v in pairs(musiclistbuttons) do v.Visible = not v.Visible end listbkg.Visible = not listbkg.Visible end) repb.MouseButton1Click:connect(function() repp.Visible = not repp.Visible rep = not rep if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end end) next.MouseButton1Click:connect(function() for i,v in pairs(musiclist) do if currentsong.Name == v.Name then if i == #musiclist then changesong(musiclist[1]) else changesong(musiclist[i+1]) end end end end) less.MouseButton1Click:connect(function() for _,v in pairs(musiclist) do if v.Volume >.1 then print("OH GOD MY EARS TURN IT DOWN") v.Volume = v.Volume -.1 end end if currentsong.Volume >.1 then print("OH GOD MY EARS TURN IT DOWN") currentsong.Volume = currentsong.Volume -.1 end end) more.MouseButton1Click:connect(function() for _,v in pairs(musiclist) do if v.Volume <1.2 then print("DJ TURN IT UP") v.Volume = v.Volume +.1 end end if currentsong.Volume <1.2 then print("DJ TURN IT UP") currentsong.Volume = currentsong.Volume +.1 end end) currentsong.Parent = M currentsong:play() musiclistbuttons[1].BackgroundTransparency = 0 playsong(currentsong)
This goes in the (SONGS) catagory.
Nice to see you again. Once again, what is the Output? (They still need a comments section here badly)