Issues with Destroy, or maybe Script Disconnect

So we use a module for handling damage, knockback, as well as normal velocity.
Lately since I’d say… maybe November of last year, we’ve been running into issues with deleting lasting effects on the character, to the point of where the Velo would ALWAYS be remaining, despite having a LOT of calls to be destroyed, whether via task.delay(), or game.Debris:AddItem() it still refuses to delete on the timer set, and instead permanently remains. I’ve checked the dev forum all over seeing if there have been other instances of this reported, and so far have found nothing.
Spawn(function() end) was added spammed into the code as a last minute resort to patching this, without just entirely just removing the function and editing it to be something better.
(this didn’t fix the issue).
As soon as the player resets, it seems to disable any and all connections to the module script INCLUDING those that should destroy the object. (this is the best thing I can figure out, or something with :Destroy() itself has messed up)
(I can’t post under Bug reports, hence posting here to ask if there’s anything I can change that can fix this without requiring an entire recode, OR if there’s a change ROBLOX did that might’ve affected this and a way to patch it safely)
Example:

module.Velocity = function(part,direction,duration)
local v = Instance.new("BodyVelocity",part)
spawn(function()
		v.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		v.Velocity = direction
		if duration then
			task.delay(duration, v.Destroy, v)
			task.spawn(function()
				game.Debris:AddItem(v,duration)
			end)
		end
	end)
end)

Please use a code block by surrounding your script with three backticks at the beginning and end.

1 Like

Alright, done so. Thanks for the heads up, didn’t know that was needed lol.
Just trying to get this issue fixed, as it’s become a somewhat been big deal to how my game functions as a whole sadly so I rushed to type this all