|
| 07 Aug 2012 02:47 PM |
Classname of all the sounds in Workspace and destroy them with a Stop All Sounds Button?
function sm64() Instance.new("Sound",game.Workspace) game.Workspace.Sound.Name = "SM64" game.Workspace.SM64.SoundId = "http://www.roblox.com/asset/?id=1280470" game.Workspace.SM64:Play() end script.Parent.MouseButton1Click:connect(sm64)
Like how would I destroy this? I know I could just game.Workspace.SM64:Stop() game.Workspace.SM64:Destroy()
But I want to remove all the sounds, not just one sound at once. So I need to destroy the Classname sound in Workspace IsA:? Im not sure can someone help me? |
|
|
| Report Abuse |
|
|
human
|
  |
| Joined: 06 May 2007 |
| Total Posts: 2765 |
|
|
| 07 Aug 2012 02:58 PM |
local sounds = game.Workspace:GetChildren() for i, v in pairs(sounds) do if v.Name == "SM64" then v:remove() end end |
|
|
| Report Abuse |
|
|
human
|
  |
| Joined: 06 May 2007 |
| Total Posts: 2765 |
|
|
| 07 Aug 2012 03:02 PM |
if theirs named diff use
local sounds = game.Workspace:GetChildren() for i, v in pairs(sounds) do if v:IsA("Sound") then v:remove() end end |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
| |
|
|
| 07 Aug 2012 03:05 PM |
for _, v in pairs(Workspace:GetChildren()) do if v:IsA("Sound") then v:Destroy() end end
if you want to destroy all sounds nested within the workspace, you should use a recursive function to sort through the workspace. |
|
|
| Report Abuse |
|
|
| |
|