Why return does not stop renderstepped from going?

I’m having issues, where this renderstepped is run when I start to mine, and idea is it’s supposed to either stop the function when you either move your mouse from one block to another, or if you have finished mining it. However, when you finish mining the block, it prints DONE and NOT SAME. It should be disconnecting the render, and returning before even getting to the NOT SAME print, so why is it printing this line??

Note, this renderstepped is inside self:Use() This creates an issue, cause both cases fire the Use function, so every time I mine a block, this function doubles, and doubles and doubles, which I don’t want.

self.RenderConnection = RunService.RenderStepped:Connect(function(deltaTime)
		MiningTimeLeft -= deltaTime
		
		if MiningTimeLeft <= 0 then -- Block finished mining
			self.RenderConnection:Disconnect()
			self.RenderConnection = nil
			
			self:Finish() -- Finish mining
			print("DONE")
			self:Use()
			return
		end
		
		if self.CurrentBlock ~= self:GetRay() then -- Moved mouse onto different block
			self.RenderConnection:Disconnect()
			self.RenderConnection = nil
			
			self:Stop() -- Stop mining current block
			print("NOT SAME")
			self:Use() -- Start mining new selection
		end
	end)
1 Like

I am doing that…

self.RenderConnection:Disconnect()

I’m thinking this is happening for 1 of 2 reasons:

1- how you’re handling your connections,
2- self:Finish or self:Use is asynchronous.

Could you provide how you’re handling your connection/how the object is being created (I assume you’re using OOP), or could you confirm that one or both of the functions I mentioned are asynchronous or not?