|
| 31 Oct 2014 04:23 PM |
I was hoping to use it, it would make my script a bit easer then using global variables and repeat loops.
Is there any other way of doing it?
|
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 31 Oct 2014 04:24 PM |
| RBXScriptConnection:disconnect() |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2014 04:24 PM |
FedoraKid, yes it is returns an error message |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2014 04:25 PM |
WELL I GOT AN ERROR SAYING IT WAS!!! Sorry, capslock. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 31 Oct 2014 04:26 PM |
Seriously? Damnit...why would it be deprecated?
Honestly I was thinking of using it just yesterday, but I rather figured I could just run checks in the touched event instead of taking the bother to disconnect...
Disconnect could come in handy though. |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2014 04:27 PM |
| It's still usable in a different way |
|
|
| Report Abuse |
|
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 31 Oct 2014 04:27 PM |
| Yeah I could still use it, but It's faster just running checks in the event than :disconnect.. |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2014 04:30 PM |
| :disconnect() is still easier. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 31 Oct 2014 04:45 PM |
Not in my opinion, for example
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") and script.Parent.Transparency ~= 1 then --stuff end end)
While for example in disconnect, you'd have to disconnect it when, let's say if the brick is invisible, while I could just do a check like this. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 31 Oct 2014 05:52 PM |
| Why would someone ever want to disconnect an event :O? |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2014 05:59 PM |
@cntkillme
Don't know, but I guess there are reasons. I know ROBLOX uses it in their animation script, for example.
~The herp lerped a derp~ |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2014 06:58 PM |
This is why you would want to use it.
function on2D () cam.CameraType=Enum.CameraType.Scriptable while true do cam:Interpolate(CFrame.new(player.Character.Torso.Position)* CFrame.new(-20,0,2), player.Character.Torso.CFrame, .5) wait(.6) end end function on3D() cam.CameraType=Enum.CameraType.Follow end dem=workspace.PlayersDemChanger:WaitForChild(player.Name.."DemChanger2") dem.OnClientEvent:connect(on2D) dem2=workspace.PlayersDemChanger:WaitForChild(player.Name.."DemChanger3") dem.OnClientEvent:connect(on3D) dem.OnClientEvent:disconnect(on2D) |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2014 07:49 PM |
Oh cool you can disconnect Remote/BindableFunctions! xD.
Anyway, I'm kind of surprised that it's deprecated, maybe its due to some bug or something. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 05 Nov 2014 08:06 PM |
Its only deprecated/broken like this
script.Parent.Touched:connect(function(object) print("1") script.Parent.TouchInterest:disconnect() end)
do this
local self; self = script.Parent.Touched:connect(function(object) print("1") self:disconnect() end) |
|
|
| Report Abuse |
|
|
| |
|
einsteinK
|
  |
| Joined: 22 May 2011 |
| Total Posts: 1015 |
|
|
| 08 Nov 2014 01:58 PM |
More or less what 128GB said.
A long time ago, you could do 'event:disconnect()' to disconnect all connections. Now, connecting to an event returns a connection: local connection = event:connect(handlerFunction) You can then disconnect that connection with: connection:disconnect()
A thing a lot of people try, is this: local con = event:connect(function() con:disconnect() dostuff() end)
That'll error, saying that 'global con is nil' That's because in reality, the function is created before 'con' is declared.
A simple fix is just doing this: local con con = event:connect(function() con:disconnect() dostuff() end) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 08 Nov 2014 08:51 PM |
'local con con = event:connect(function()'
Thats the same thing as this but on 1 line
local self; self = script.Parent.Touched:connect(function(object) print("1") self:disconnect() end)' |
|
|
| Report Abuse |
|
|
|
| 11 Nov 2014 08:26 AM |
Oh, does the event have to be running in order to disconnect it? I guess that makes sense. |
|
|
| Report Abuse |
|
|
inapt
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 11666 |
|
|
| 11 Nov 2014 10:30 AM |
not depreciated...?
local event; event = part.Touched:connect(function(hit) print(hit.Name) event:disconnect() end)
-ForeverDev |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 11 Nov 2014 03:39 PM |
No it doesn't have to be running local event = workspace.ChildAdded:connect(function(child) print(child.Name) end) event:disconnect() |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2014 07:26 AM |
| Okay, so you can only disconnect an event if you set as a variable the event which is connected to a function? I have a feeling that it would still error. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 12 Nov 2014 11:38 AM |
It wouldn't error
And no but reasonable you would always set a variable to it and disconnect it later
workspace.ChildAdded:connect(function(child) print(child.Name) end):disconnect()
Works, but is pointless |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 12 Nov 2014 11:49 AM |
If you want something only to run once, then wrap it into a coroutine and use :wait instead hehe If you need it to disconnect under specific conditions, there are always better ways of doing it but 128's method works just fine. |
|
|
| Report Abuse |
|
|