Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to Disconnect a Function?

Asked by 5 years ago

How do I disconnect the OnClientEvent or Disable it?

1local a = true
2 
3RemoteEvent.OnClientEvent:Connect(function(b)
4    if a == false then
5    :Disconnect(b)
6end)

1 answer

Log in to vote
4
Answered by 5 years ago
Edited 5 years ago

The :Connect method returns a signal object which you can disconnect to disconnect that signal like so:

1local a = true
2 
3local connection
4connection = RemoteEvent.OnClientEvent:Connect(function(b)
5    if a == false then
6        connection:Disconnect()
7    end
8end)
0
Can i Disconnect the FireClient() on the server? ffancyaxax12 181 — 5y
0
OmG IM sooo Stupid. (Your right Btw) I just forgot to do someting else. ffancyaxax12 181 — 5y
0
Thank Ya :) ffancyaxax12 181 — 5y
Ad

Answer this question