Is there any way to delete a function?

for throwing some tool, i have to make a function that work when the tool’s part got hit.

but after hit, it have to be not activated. so, the function became useless.

i don’t want the function taking up memory. how to delete useless function?

function throw(tool)

like this. hit() works after tool is not in air.

1 Like

You can create a Connection for it.

-- Creates a new Connection
local SomeConnection = SomeEvent:Connect(function()


-- Disconnects the Connection, It won't be triggered anymore
SomeConnection = nil
1 Like

you have to just let the function finish and then it will be garbage collected.

functions with infinite loops or event connections will never be garbage collected, for those you need to break the loops and disconnect the signals.