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: Disconnect event within connection?

Previous Thread :: Next Thread 
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
10 Nov 2016 04:27 PM
Is it possible to :disconnect() within a :connect()?

so like:

a = part.Touched:Connect(function(t)
a:Disconnect()
end)


Report Abuse
DevVince is not online. DevVince
Joined: 08 Nov 2008
Total Posts: 9245
10 Nov 2016 04:29 PM
You can disconnect out side of the function but I've never tried to disconnect it inside of the function you might be able to but you'll need to test it.
Report Abuse
secretidagent is online. secretidagent
Joined: 07 Nov 2010
Total Posts: 1600
10 Nov 2016 04:30 PM
Yes.
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
10 Nov 2016 04:31 PM
I tested it and it doesn't work, which is why I posted the thread ^^ :P


I was wondering if somebody else knew how to do what I'm trying to do. I provided that as an example since I already tried it.


Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
10 Nov 2016 04:34 PM
To specify, I tested it within RenderStepped and Touched with no luck.




Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Nov 2016 04:36 PM
it does work
1owercase the D in disconnect and C in connect
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
10 Nov 2016 04:38 PM
Why is the case relevant? I'm pretty sure :connect and :disconnect are deprecated as well


Report Abuse
DevVince is not online. DevVince
Joined: 08 Nov 2008
Total Posts: 9245
10 Nov 2016 04:38 PM
--You can do something like this:
script.Parent.Touched:connect(function()
local Disable = false
local a = function()
--Run code?
Disable = true
end
a()
repeat wait() until Disable
a:Disconnect()
end)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Nov 2016 04:41 PM
Oh, I thought Connect and Disconnect didn't exist.
Anyways your code is fine
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
10 Nov 2016 05:12 PM
Doesn't work for me within RenderStepped.


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Nov 2016 05:16 PM
How does your code look
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
10 Nov 2016 05:17 PM
hot & ready for a date

I think I fixed it though will report back in a sec


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
10 Nov 2016 05:36 PM
unbindfromrenderstepped *


Report Abuse
wfvj014 is not online. wfvj014
Joined: 30 Apr 2012
Total Posts: 145
10 Nov 2016 05:38 PM
Yes.

Name the variable outside the function then rename it.

local x

a = part.Touched:Connect(function(t)
a:Disconnect()
end)
Report Abuse
wfvj014 is not online. wfvj014
Joined: 30 Apr 2012
Total Posts: 145
10 Nov 2016 05:40 PM
Not sure why, but I named my variables different things.....

Use x lol

local x

x = part.Touched:Connect(function()
x:Disconnect()
end)
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