I’m working on a Tower Defense type game, and I’m struggling with a part of it. Whenever one of the towers I have placed down shoots an enemy, it will give the owner of the tower the amount of damage it dealt to the enemy. Problem is, if there are too many towers together and shooting at the same time, this amount can become negative, and reduce a lot of my money instead. How can I fix this issue?
Here is my code so far:
if plr then plr.Cash.Value += math.min(damage.Value, target.Humanoid.Health) end target.Humanoid:TakeDamage(damage.Value)