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 » Scripters
Home Search
 

Re: fire virus

Previous Thread :: Next Thread 
chlomo12345 is not online. chlomo12345
Joined: 17 May 2016
Total Posts: 11
20 Feb 2017 12:49 PM
does anyone know how to get rid of the fire virus in a game?
Report Abuse
LawrenceWindsor is not online. LawrenceWindsor
Joined: 08 Mar 2015
Total Posts: 527
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
icekiller8002 is not online. icekiller8002
Joined: 22 Jan 2013
Total Posts: 6636
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
icekiller8002 is not online. icekiller8002
Joined: 22 Jan 2013
Total Posts: 6636
20 Feb 2017 01:14 PM
ROBLOX you better watch out ッ
Report Abuse
Casualist is not online. 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
LawrenceWindsor is not online. LawrenceWindsor
Joined: 08 Mar 2015
Total Posts: 527
20 Feb 2017 01:18 PM
^ Do not use that, that will crash your game


Report Abuse
Xonae is online. 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 is not online. 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
LawrenceWindsor is not online. LawrenceWindsor
Joined: 08 Mar 2015
Total Posts: 527
20 Feb 2017 01:20 PM
Congratulations, you pretty much created a lag script lmao


Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
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 is not online. 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 is not online. 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
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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