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 4 years ago

How do I disconnect the OnClientEvent or Disable it?

local a = true

RemoteEvent.OnClientEvent:Connect(function(b)
    if a == false then
    :Disconnect(b)
end)

1 answer

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

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

local a = true

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

Answer this question