Why does this print '0' at sometimes?

The damage drop off function prints ‘0’ sometimes and prints the right amount of damage to deal sometimes.

I have not found any thing similar to my issue here.

local percentDamage = math.clamp(75/distance, 30/distance, 1)
local dropOffDamage = math.round(percentDamage * damage)
print(dropOffDamage)

75 is the max distance, 30 is the minimum.

i think its because there are cases when math.round(75/distance) = 0 try printing this 75/distance and see how much is it

1 Like

image

Top print is 75/distance
Bottom is the dropOffDamage (i removed the math.round)

It will still print 0 at some times for some reason though such as here:
image

I have no clue why this is happening.

1 Like

how much is the damage charsss

and is the distance just math.random

distance = (origin - mouse.Hit.Position).Magnitude
damage = 18

can you try to pring percentDamage and tell me because this looks really weird lol

If distance is ever 0 you’d be dividing by 0.