#Dont know how to end functions with event listeners
13 messages · Page 1 of 1 (latest)
Disconnect them when they're no longer needed
It's a simple as that
if you want it disconnect as soon as its run once
you can use :Once() instead of :Connect()
if you want to know how to disconnect connections generally
define the connection in a variable and call the :Disconnect() event on the variable that defines the connection
for example
part = workspace.Part
connection = part.Touched:Connect(function()
-- blah blah blah
end)
task.wait(3) -- lets say you wanted it to disconnect after 3 seconds
connection:Disconnect()
Avoid declaring these as global variables, though
yeah I wrote it in like 5s