Pegagittt
(Pegagit)
August 14, 2022, 12:02pm
#1
How do i disconnect the function, NOT the MouseButton1Click Event.
I want if the Player click the Button that the function a() should not start twice, so i want to disconnect the function a(), how do i do that?
local connection
local function a()
connection:Disconnect()
end
connection = script.Parent.MouseButton1Click:Connect(a)
I’m not too sure what you mean. In this case, you can only disconnect the MouseButton1Click, which is what you’re doing.
Mystxry12
(Mystxry)
August 14, 2022, 12:07pm
#3
local connection
local function a()
connection:Disconnect()
return
end
connection = script.Parent.MouseButton1Click:Connect(a)
1 Like
Pegagittt
(Pegagit)
August 14, 2022, 12:08pm
#4
The Player cant click the Button again, i dont want to disconnect the MouseButton1Click, i want to Disconnect just the function
I’m almost certain that would disconnect the connection before you can click.
I don’t think it yields
Mystxry12
(Mystxry)
August 14, 2022, 12:11pm
#7
local connection
local function a()
connection:Disconnect()
end
connection = script.Parent.MouseButton1Click:Connect(a)
The player wont be able to click the button again if the above code runs, since the connection gets disconnected.
In this case, you wouldn’t need to disconnect anything?
Just do this
local function a()
-- code here
end
script.Parent.MouseButton1Click:Connect(a)
TenBlocke
(Decablocks)
August 14, 2022, 12:12pm
#9
You can just use :Once(), and create another connection in the function that fires only once
local newconnection
local function a()
newconnection = script.Parent.Event:Connect(function()
--code
end)
end
script.Parent.MouseButton1Click:Once(a)