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: How can I disconnect an anonymous event?

Previous Thread :: Next Thread 
TheAltOfDavid12 is not online. TheAltOfDavid12
Joined: 05 Feb 2014
Total Posts: 352
10 Jun 2014 09:29 PM
I'm making a basic fire spreading script, where I want bricks to catch fire if they come into contact with other fire bricks. Eventually, I want the .Touched event to disconnect. This is what I currently have, but I get an error saying it's a depreciated method.

--not exactly what I have, just basic

function addFire(part)
--put fire in the part
part.Touched:connect(function(hit)
if hit:IsA("BasePart") then
wait(5)
addFire(hit)
wait(15)
part.Touched:disconnect() --this is where I get the error
end
end)
end
Report Abuse
TheAltOfDavid12 is not online. TheAltOfDavid12
Joined: 05 Feb 2014
Total Posts: 352
10 Jun 2014 09:32 PM
bump
Report Abuse
TheAltOfDavid12 is not online. TheAltOfDavid12
Joined: 05 Feb 2014
Total Posts: 352
10 Jun 2014 09:34 PM
@cnt

Help me pl0x



★ Offering Emp + R$15 for Domino Crown ★
Report Abuse
veryveryveryhidden is not online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
10 Jun 2014 09:34 PM
you don't
Report Abuse
TheAltOfDavid12 is not online. TheAltOfDavid12
Joined: 05 Feb 2014
Total Posts: 352
10 Jun 2014 09:35 PM
@very

Thanks for the useful advice.



★ Offering Emp + R$15 for Domino Crown ★
Report Abuse
veryveryveryhidden is not online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
10 Jun 2014 09:35 PM
actually


local func=Workspace.Part.Touched:connect(function() print'hi' end) func:disconnect()
Report Abuse
TheAltOfDavid12 is not online. TheAltOfDavid12
Joined: 05 Feb 2014
Total Posts: 352
10 Jun 2014 09:36 PM
Oh, thank you.



★ Offering Emp + R$15 for Domino Crown ★
Report Abuse
TheAltOfDavid12 is not online. TheAltOfDavid12
Joined: 05 Feb 2014
Total Posts: 352
10 Jun 2014 09:37 PM
Actually, it's saying 'event' is a nil value. This is the script copied and pasted.

local event = hit.Touched:connect(function(touch)
if touch:IsA("BasePart") and not touch.Parent:FindFirstChild("Humanoid") and touch.Name ~= "Platform" and not touch:FindFirstChild("Fire") then
wait(5)
addFire(touch)
wait(15)
event:disconnect()
elseif touch.Parent:FindFirstChild("Humanoid") then
touch.Parent.Humanoid:TakeDamage(2.5)
end
end)



★ Offering Emp + R$15 for Domino Crown ★
Report Abuse
TheAltOfDavid12 is not online. TheAltOfDavid12
Joined: 05 Feb 2014
Total Posts: 352
10 Jun 2014 09:42 PM
Ahh, I found the answer on the wiki. It's kind of weird, but this is what it said:

You will soon notice that you've run into an error saying that con is a nil value. This happens because the con variable wasn't assigned before the anonymous listener was created. To get around this, all you have to do predefine the con variable:



★ Offering Emp + R$15 for Domino Crown ★
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