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)