How do I disconnect the OnClientEvent or Disable it?
1 | local a = true |
2 |
3 | RemoteEvent.OnClientEvent:Connect( function (b) |
4 | if a = = false then |
5 | :Disconnect(b) |
6 | end ) |
The :Connect
method returns a signal object which you can disconnect to disconnect that signal like so:
1 | local a = true |
2 |
3 | local connection |
4 | connection = RemoteEvent.OnClientEvent:Connect( function (b) |
5 | if a = = false then |
6 | connection:Disconnect() |
7 | end |
8 | end ) |