|
| 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
|
  |
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 10 Nov 2016 04:34 PM |
To specify, I tested it within RenderStepped and Touched with no luck.
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 10 Nov 2016 05:12 PM |
Doesn't work for me within RenderStepped.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 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
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
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
|
  |
| 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 |
|
|