I want to know how to measure the distance the part flew/went for example, Bullet; when reached range <= 100 then do damage - 10. that was just an example of the thing I wanted to know...
You would do something like this:
local Bullet = script.Parent --Change this to the path of the bullet local Active = true coroutine.resume(coroutine.create(function() local StartPos = Bullet.Position while true do if (Bullet.Position - StartPos).magnitude > 100 then --If the distance between the StartPos and the Bullet is > 100... Active = false break end wait() end end)) Bullet.Touched:connect(function(Obj) if Active then --If the bullet hasn't reached a range of > 100... --Do stuff elseif (not Active) then --If the bullet has reached a range of > 100... --Do stuff end end)
EDIT This is a much simpler version that LightArceus suggested:
local Bullet = script.Parent --Change this to the path of the bullet local StartPos = Bullet.Position Bullet.Touched:connect(function(Obj) local BulletDist = (Bullet.Position - StartPos).magnitude if BulletDist > 100 then --If the bullet hasn't reached a range of > 100... --Do stuff elseif BulletDist <= 100 then --If the bullet has reached a range of > 100... --Do stuff end end)