|
| 24 Mar 2014 05:41 AM |
This works well, and fine;
while true do wait(0.01) parts = game.Workspace:GetChildren() repeat for i = 1,#parts do if parts[i].ClassName == "Sound" then parts[i]:Destroy() end end end
and so would this; game:FindFirstChild("Sound", true)
to search through the game. But how can I make my above script do that, as the name is not always Sound, so I want to make parts search through EVERYTHING, or the for statement. Either one. Anybody know how I can easily do this? |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 05:47 AM |
Possibly turn game's children to a table and then turn the children of game to a table.
stuff = game:GetChildren(); stuff2 = stuff:GetChildren(); --Of course it won't work as easily as that.
|
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 06:02 AM |
| I was hoping I could use a recursive... or use something like FindFirstChild except for classname? |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 06:06 AM |
function find(model) for _,v in pairs(model:GetChildren()) do if v:IsA("Sound") then v:Destroy() else find(v) end end end
--Like this? |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 24 Mar 2014 06:08 AM |
| But you made a lagg script also... |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 06:29 AM |
| In theory, the least laggiest way is to use an ObjectValue. |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 24 Mar 2014 06:31 AM |
Atill i think this would lagg Minimized wait with endless loop to get everythingg in a game, and check a property for it. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 07:08 AM |
I made some modifications to robust's script, if this is laggy, and its possible, can somebody make this less laggy?
function _G.find(model) for _v, in pairs(model:GetChildren()) do if v:IsA("Sound") then v:Destroy() else vs = v:GetChildren() if #vs ~= 0 then find(v) end end end end
while true do wait(0.01) _G.find(game) end |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 07:15 AM |
function find(model) for _,v in pairs(model:GetChildren()) do --This loop won't run if the #children == 0 if v:IsA("Sound") then v:Destroy() else find(v) end end end
workspace.DescendantAdded:connect(function(child) --If ANY object is added to workspace (it doesn't matter where, it could be inside workspace.Model.Model.Model and still function fine) if child:IsA("Sound") then children:Destroy() end end)
--I haven't tested this, but I do believe this should work just fine. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 07:21 AM |
| Robust that last one is perfect! Thank you! HallowMariofan likes to make sounds, I used the first script I posted, but he likes to make Tetris bricks ran, so he might get the crazy idea as to insert his "swag" music in them! This will work perfectly, and will help with lag! But one question, would that get rid of sound if its inserted INSIDE a brick that inserted, or would it only scan the brick? |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 07:22 AM |
| What if he sets the parent to nil? |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 24 Mar 2014 07:23 AM |
| I would create the same as robust, its the best, also war, you joined on my bdate. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 07:28 AM |
function find(model) for _,v in pairs(model:GetChildren()) do --This loop won't run if the #children == 0 if v:IsA("Sound") then v:Destroy() else find(v) end end end
workspace.DescendantAdded:connect(function(child) --If ANY object is added to workspace (it doesn't matter where, it could be inside workspace.Model.Model.Model and still function fine) if child:IsA("Sound") then child:Destroy() else find(child) --Search through the child that was added to remove any sounds that might exist end end)
--I did a small mistake, but it should work like this now. And I think it should work fine even if the parent is set to nil.
|
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 07:31 AM |
| Seriously? Oh my gosh, its fate! lol |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2014 07:33 AM |
| Why search through the children? Wouldn't descendent added cover that too? |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
| |
|
|
| 24 Mar 2014 08:25 AM |
Workspace.DescendantAdded:connect(function(c) if c:isA"Sound" then c:Destroy() end end) |
|
|
| Report Abuse |
|
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
| |
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 24 Mar 2014 08:32 AM |
Ik lol
Going for the 4750, then for 5k Geez man this is a lot |
|
|
| Report Abuse |
|
|