Most efficient way to detect when large number of welds drops below a threshold

A quick question about efficciency:

I have a game where objects get destroyed when they are hit by removing ManualWelds in that area, and I set it up so that all welds in a model are parented to the same part. I want to count the number of remaining total welds in the model so I know when to respawn that model. Right now I have this script running inside the part that all welds in the model are parented to:

weldNum = 1362

script.Parent.ChildRemoved:Connect(function(instance)
	weldNum = weldNum - 1
	print(weldNum)
end)

The thing is, this specific model has 1,362 welds in it, and I am worried that relying on an event being fired every single time 1 weld is destroyed would be inefficient, especially because I would have perhaps 8 of these models in the map at once all doing the same thing. I ran this script and it seemed fine so far.

The only other alternative I could think of would be to count the number of welds every 10 seconds or so, but again, this would be happening constantly for about 8 different models at the same time. Any suggestions?

Depending on where the Script is parented, it should only fire when the objects direct children is Removed, and not its Descendants (or the children of the children).

Events are pretty Efficient, not really more efficient you can go from there.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.