#help with function disconnection

19 messages · Page 1 of 1 (latest)

smoky fern
#

when the autoclicker is deactivated and the player is holding a tool it fires this

cobalt patio
#

pretty sure u cant use :Disconnect on functions unless thats just something ive been unaware of

#

Just add a bool into while true do in punch and set the bool to false when u want the function to stop running

smoky fern
#

disconnect is a thing ye

cobalt patio
#
function punch()
while INSERT_BOOL do
task.wait()
end
end

--other code whatever
INSERT_BOOL = false -- stop punch 
smoky fern
#

ok ill try

cobalt patio
#

You use it to disconnect function from things like :Connect

#

example:

local connection
connection = script.Parent.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid")
        part.Parent.Humanoid.Health = 0
        connection:Disconnect()
    end
end)
smoky fern
#

ic

cobalt patio
#
#

So hence why it was giving you the error

#

since you were using it for the wrong things

smoky fern
#

thx

cobalt patio
#

no worries!

rapid pumice
#

you have to do sum like

#

heres an example of a part function

#
local touchEvent = yourpart.Touched:Connect(function(arguments)
    
end)

touchEvent:Disconnect()