Mouse Down code
function Play:OnMouseDown()
self._maid:GiveTask(self.instance.MouseButton1Down:Connect(function()
-- do stuff
end))
self:Deinit()
end
Deinit code
function Play:Deinit()
self._maid:DoCleaning()
end
Is this a good way of disconnecting a maid? Or should I just call :DoCleaning()
inside of the OnMouseDown()
function?
Thanks.
1 Like
There is no functional difference from doing it in the OnMouseDown
function and creating its own function for it. Although with what you currently have, there is no real purpose to assign its own function unless you add more to the Deinit
function.
What you are doing now would be a tiny bit slower due to the need to index self
for Deinit
and it would be more effective to just put self._maid:DoCleaning()
in the OnMouseDown
function
2 Likes
Thank you! For now I’m going to do what use suggested and put :DoCleaning()
inside of the OnMouseDown
because I don’t have reason to put any code inside of the deinit function.
Thanks for the tip!
1 Like