Is it possible to disconnect all events inside a function with one single line of code?

Is it possible to disconnect all events inside a function with one single line of code or multiple, i’m just looking for a way to save time. I can’t be bothered disconnecting 1760 lines of code :sob:

i donot know but maybe try asking the ai thing to disconnect all of them?

bro that’s what im trying to do :sob:, the ai literally says im over the letter limit

2 Likes

ok maybe try copying every part of your code in many scripts and ask the ai to do that for each one and then add them in 1 script again but copy your main script first bc it may break

Ok, i’ll do that and then get back to you

1 Like

Yes. Store all of the events that are currently connected into a table by storing each of them into a list when you connect them.

Example:

events = {}
events[eventName] = object.Touched:Connect(function()
     --stuff here
end)

Then, loop through the table and disconnect each of the events

for _, v in events do
    v:Disconnect()
end
1 Like

So i’ve done what you’ve asked me to do, is it ok to have 15 - 30 events on server that need to always be on?

It should be fine as long as you’re not calling them too often (like, once per frame or something would be too much)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.