# Function has extreme delay or just sometimes doesnt work as intended

Idk what happened i swear it was working normally before but now it just sometimes doesnt work / has a long delay (3-4 seconds) on it

``````local ExplosivePart = script.Parent

local Touched = true
local Debug = true
local Vx = 0
local Vy = 0
local Vz = 0

local StartedFall = false
local EndedFall = false

local StartTime = tick()
local EndTime = tick()

local StartPos = Vector3.zero
local TouchedPos = Vector3.zero

local Force

ExplosivePart.Touched:Connect(function(Part)
Touched = true
TouchedPos = ExplosivePart.Position
end)

local V = ExplosivePart.AssemblyLinearVelocity

local X1 = if math.abs(V.X) > 0 then math.abs(V.X) else 0
local Y1 = if math.abs(V.Y) > 0 then math.abs(V.Y) else 0
local Z1 = if math.abs(V.Z) > 0 then math.abs(V.Z) else 0

if X1 > Vx then Vx = X1 end
if Y1 > Vy then Vy = Y1 end
if Z1 > Vz then Vz = Z1 end

if Vy > 10 or Vx > 10 or Vz > 10 then
if not StartedFall then StartTime = tick(); StartPos = ExplosivePart.Position; StartedFall = true end
end

if StartedFall then
print("d")
if Touched then
local hit = false
local V2 = ExplosivePart.Velocity

if Vx-V2.X > Vx*0.80 then hit = true end
if Vy-V2.Y > Vy*0.80 then hit = true end
if Vz-V2.Z > Vz*0.80 then hit = true end

if hit then
EndTime = tick()

local Vctr = (Vx+Vy+Vz)
local Mass = ExplosivePart.Mass
local Distance = (TouchedPos - StartPos).Magnitude

if Distance < 10*(Mass/4) then Distance = 10*(Mass/4) end
Force = Mass * Vctr / (2 * Distance)

if Force >= 5 then
ExplosivePart:FindFirstChildWhichIsA("Humanoid"):TakeDamage(Force)
end

Vx = 0
Vy = 0
Vz = 0

Distance = nil
StartedFall = false
Touched = false
hit = false

if Debug then
print(Force)
print("Part fell for " .. EndTime - StartTime .. " Seconds")
end
else
Touched = false
end
end
end
end
``````