upon calling startSmoke on more than one object the object that isn’t the first doesn’t disconnect its loop when called for and kinda just lingers around for a little bit.
function module:startSmoke(part,decayTime,sizeAmplification, originalColor, fadeto)
spawn(function()
local elapsed = 0
> smokeLoop = game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
end)
part.AncestryChanged:Connect(function()
smokeLoop:Disconnect() -- DOESN'T CANCEL ON THE SECOND
end)
end)
end
Where is the smokeLoop defined? Use local smokeLoop to ensure, that the variable will exist only in current context, and reference won’t be changed.
The issue might be, that you’re creating smokeLoop variable in module context, which means that that first startSmoke will set smokeLoop = 0x01, second call will set smokeLoop = 0x02, and when AncestryChanged signal is called, it will disconnect 0x02 in both parts. Because smokeLoop is referencing 0x02.
local smokeLoop = ...
part.AncestryChanged:Connect(function()
smokeLoop:Disconnect()
end)