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: Okay, so I can do this, but how do I do that?

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
24 Mar 2014 06:02 AM
I was hoping I could use a recursive... or use something like FindFirstChild except for classname?
Report Abuse
RobustPhysics is not online. RobustPhysics
Joined: 12 Jul 2012
Total Posts: 3064
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 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
24 Mar 2014 06:08 AM
But you made a lagg script also...
Report Abuse
Bebee2 is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
RobustPhysics is not online. RobustPhysics
Joined: 12 Jul 2012
Total Posts: 3064
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
24 Mar 2014 07:22 AM
What if he sets the parent to nil?
Report Abuse
vlekje513 is not online. 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
RobustPhysics is not online. RobustPhysics
Joined: 12 Jul 2012
Total Posts: 3064
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
24 Mar 2014 07:31 AM
Seriously? Oh my gosh, its fate! lol
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
24 Mar 2014 07:33 AM
Why search through the children? Wouldn't descendent added cover that too?
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
24 Mar 2014 08:13 AM
1500 posts ^
Report Abuse
littleAU999 is not online. littleAU999
Joined: 15 Jan 2011
Total Posts: 1375
24 Mar 2014 08:25 AM
Workspace.DescendantAdded:connect(function(c)
if c:isA"Sound" then
c:Destroy()
end
end)
Report Abuse
L0cky2013 is not online. L0cky2013
Joined: 30 Jul 2012
Total Posts: 1446
24 Mar 2014 08:26 AM
4500 posts ^
Report Abuse
L0cky2013 is not online. L0cky2013
Joined: 30 Jul 2012
Total Posts: 1446
24 Mar 2014 08:29 AM
@vl*
Report Abuse
vlekje513 is not online. 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
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