Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can someone tell me how to get the sounds that have been deleted and stop them?[UNANSWERED!]

I really need help with this! 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 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)
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
for i, v in pairs(script.Parent:GetChildren()) do
	if v:IsA("Song") then
		v:stop()
		end
	end
currentsong:stop()
wait(0.1)
currentsong:remove()
print("Successfully Removed the last song")
currentsong = song:clone()
currentsong.Parent = M
if playing then
	for i, v in pairs(script.Parent:GetChildren()) do
	if v:IsA("Song") then
		v:play()
		end
	end
	print("Changed Song")
currentsong:play()
playsong(currentsong)
end
end



stop.MouseButton1Click:connect(function()
if playing then
playing = false
stopp.Style = "ChatGreen"
stop.Text = "Play"
currentsong:stop()
else
stopp.Style = "ChatRed"
if script.Parent.ColG.Text ~= "Disco Hangout[2.0]" then M:remove() end
stop.Text = "Stop"
playing = true
currentsong:play()
print("Play 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
v.Volume = v.Volume -.1
end
end
if currentsong.Volume >.1 then
currentsong.Volume = currentsong.Volume -.1
end
end)

more.MouseButton1Click:connect(function()
for _,v in pairs(musiclist) do
if v.Volume <1.2 then
v.Volume = v.Volume +.1
end
end
if currentsong.Volume <1.2 then
currentsong.Volume = currentsong.Volume +.1
end
end)


currentsong.Parent = M
currentsong:play()
musiclistbuttons[1].BackgroundTransparency = 0
playsong(currentsong)

1 answer

✓ Accepted answer

It's impossible. You'll have to stop the sounds before you destroy them.

2 comments

0

Can you help me with this? I can't figure out why it isn't stopping before so. I'll update my question with the script.

0

Its now when i switch a song it keeps switching songs over and over and over and it says "Succsessfully removed last song but its playing two songs at once."

This discussion is preserved as it was. New answers, comments, and votes are closed.