Having trouble for a while now:

if game.Workspace:FindFirstChild("Music") then
	game.Workspace:WaitForChild("Music"):Stop()
	game.Workspace:FindFirstChild("Music"):remove()
end

I added prints inbetween and they both ran ("Stopped"), ("Removed") yet the sound continued to play..? before their was a Sound called 'Instance' in workspace and it was removed but wasn't stopped, not sure why it's not stopping.

This is how it's created:

function CreateSound()
	Music = Instance.new("Sound")
	Music.Name = "Music"
	Music.Looped = false
	Music.Parent = game.Workspace
	Music.PlayOnRemove = false
end

1 comment

0

Your conditional checks to see if Music exists, that's okay, but then your WaitForChild does what it says which means it waits for a child called "Music" to be added to workspace. It already exists so it won't work.