|
| 20 Feb 2017 12:49 PM |
| does anyone know how to get rid of the fire virus in a game? |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2017 12:51 PM |
Long story short: don't use free models
But if you're that rebel that insists otherwise, here you go function recur(instance) if #(instance:GetChildren()) > 1 then for i,v in pairs(instance:GetChildren()) do if v:IsA('Fire') then v:Destroy() end recur(v) end end end
recur(workspace)
|
|
|
| Report Abuse |
|
|
|
| 20 Feb 2017 01:11 PM |
| function recur(instance) if #(instance:GetChildren()) > 1 then for i,v in pairs(instance:GetChildren()) do if v:IsA('Fire') then if ######################## ## nil then ################## end end ######## end end end recur(workspace) |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2017 01:14 PM |
| ROBLOX you better watch out ッ |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 20 Feb 2017 01:17 PM |
while true do game:FindFirstChild("Spread",true).Parent:Destroy() end
~ta-da |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2017 01:18 PM |
^ Do not use that, that will crash your game
|
|
|
| Report Abuse |
|
|
Xonae
|
  |
| Joined: 04 Dec 2013 |
| Total Posts: 336 |
|
|
| 20 Feb 2017 01:19 PM |
while true do game:FindFirstChild("Spread",true).Parent:Destroy() wait() end
that should fix it.
~ Xonae ~ |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 20 Feb 2017 01:20 PM |
It won't for fairly obvious reasons.
Hint: What happens where Spread can't be found by FindFirstChild? |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2017 01:20 PM |
Congratulations, you pretty much created a lag script lmao
|
|
|
| Report Abuse |
|
|
|
| 20 Feb 2017 01:22 PM |
casualist, won't your method run a full recursion function like the other guy's every single call to FindFirstChild? that's kinda expensive
|
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 20 Feb 2017 01:26 PM |
Lol, let me break it down for you: There are a few parts to this:
while true do game:FindFirstChild("Spread", true).Parent:Destroy() end
The loop, with the conditional always being true. So the loop won't stop that way. There's no break, so it's not stopped that way. What's left? Code stops when it yields or errors. The methods used here don't have infinite yields, so the stopping mechanism must be error.
So, what this code does every loop is loop for any singular object named "Spread" and destroys it's parent (and effectively the object named "Spread"). When there are no more objects left with that name, FindFirstChild returns nil.
At this point the code is now equivalent to:
while true do (nil).Parent:Destroy() end
which will error since nil has no properties, stopping the script. So now the script has done it's job and stopped once the job is complete. |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 20 Feb 2017 01:27 PM |
| @unsub FindFirstChild is significantly fast; and since you should only plan to ever run this once in a command bar of your game, a few ms won't matter. |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2017 01:31 PM |
well, it could potentially be quite a bit more than a few milliseconds but you're right, if it's a command then it really doesn't matter
|
|
|
| Report Abuse |
|
|