Unexplainable lag

I’ve been stuck with this issue for quite a few days.

humanoid:TakeDamage(damage)

where damage is a number in my gun settings.

Every time this code is run, it creates a lot of lag on low end devices. Changing “damage” to a number lower than 5 fixes the issue, increasing the humanoid’s health from 100 to 10000 also fixes the issue, but these of course are not desirable fixes.

Disabling server or client scripts doesn’t make any difference.

I’d recommend trying out the code in different places and see if it happens aswell. Maybe in your game, visual effects are being cloned for every health loss? Can’t tell much from this information.

Well obviously the lag isn’t caused by calling take damage, you must have a function that runs whenever the health is changed and that function is causing the lag.