How do i get more high value as target closer?

In the example below, the number decreases as get closer to the target.

if (HumanoidRootPart.Position - Target.Position).magnitude < 25 then	
local dist = (HumanoidRootPart.Position - Target.Position).magnitude
print(dist) 
Humanoid:TakeDamage(dist)
end

I hope the damage will increase as get closer to the target. :blush:

I think with using magnitude, it should not be too hard, how would you want it to be like maybe?
Also we want to make it so that if we are more than a cirten distance away from the object it will always take a cirten amount of damage.
Also this was my 100th post lol

2 Likes

For humanoid take damage, the more farther away the person is away from the target, the more greater the distance, hence the more greater the damage. You can try making a equation using subtraction

Humanoid:TakeDamage(60-distance)

You can also use if statements.

if distance>75 or distance=75 then
Humanoid:TakeDamage(15)
end
if distance>60 and distance<75 then
Humanoid:TakeDamage(20)
end
if distance>45 and distance<60 or distance=60 then
Humanoid:TakeDamage(25)
end
if distance<45 or distance=45 then
Humanoid:TakeDamage(50)
end