generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Im making a Music Player but how would I find the...

Previous Thread :: Next Thread 
TheEpicSamuri is not online. TheEpicSamuri
Joined: 04 Dec 2011
Total Posts: 1343
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 is not online. 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 is not online. 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 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
07 Aug 2012 03:02 PM
Can you do ClassNames?
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
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
TheEpicSamuri is not online. TheEpicSamuri
Joined: 04 Dec 2011
Total Posts: 1343
07 Aug 2012 03:15 PM
@ doom/human

Thank you
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image