local Module = {}
Module.Start = function()
end
Module.Cancel = function()
Module.Start:Disconnect() -- Error here
end
return Module
[attempt to index field 'Start' (a function value)]
Title kinda says it all really. Tryna Disconnect the Start function (and thus stop anything that may be running inside of it, including RenderStepped events)
I’m fairly certain you can’t really disconnect a function as it isn’t making connections to anything. Could be wrong so don’t quote me exact. What you could do, if you’re wanting to stop things inside of the function, is just return a table with connections inside of it and disconnect the returned contents.
Functions are not connections. You also can’t safely stop another function if it’s in the middle of running, because Roblox Lua isn’t concurrent and the code may already have executed or have yet to start.
What you are probably looking to do is setting a boolean value within your Start/Cancel functions that dictate the state of a separate thread initiated in the module, or implementing your Start/Cancel procedures using coroutines or BindableEvent/Functions.
That’s what I had originally, but problem I found with that is that if I wanna cancel multiple functions at once then I’d have to go thru dozens of scripts.