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

Is there a new method for :disconnect()? [closed]

Asked by 7 years ago
Edited 7 years ago

I'm looking for a new method to disconnect a function, because the wiki says that the :disconnect() function is obsolete.

Here is the script I'm working on if anyone can help.

local plr = game.Players.LocalPlayer
local M = plr:GetMouse()

local fr = script.Parent
local T = fr:WaitForChild("TextLabel")

function TestFunction()
    print("Clicked")
end

M.Move:connect(function()
    fr.Position = UDim2.new(0, M.X, 0, M.Y)
    if M.Target ~= nil then
        if M.Target:IsA("Part") then
            if M.Target.Parent:FindFirstChild("Base") then
                fr.Visible = true
                T.Text = tostring(M.Target.Parent.Name)
                M.Button1Click:connect(TestFunction())
            else
                fr.Visible = false
                TestFunction:Disconnect() -- Error is here
            end
        end
    else
        fr.Visible = false
        TestFunction:Disconnect() -- Same error here
    end
end)

How could I fix this?

1
disconnect() doesn't work anymore, but using Disconnect() works fine. If you're getting an error, it's probably because your function isn't connected to an event, so there's nothing to disconnect. User#11440 120 — 7y
0
Ok thanks, I found another way too is using debounce XD maquilaque 136 — 7y

Answer this question