# Force is not decreasing velocity?

Hello everyone,
I have a script in which a part moves at a velocity, and I would like it to decrease when the input is released. So far, I used `f = ma` to determine the amount of force needed to decrease the velocity of the part, but the output gets crazy (sometimes it outputs -INF). Ask if I need to add any more info.

Here is the script:

``````userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == forward_key then
holding = true
end

while holding == true do
b_gyro.CFrame = CFrame.new(hrp.Position,mouse.Hit.p)
lv = b_gyro.CFrame.LookVector
b_velocity.Velocity = Vector3.new(lv.X * speed, lv.Y * speed, lv.Z * speed)
wait()
initial_Vel = b_velocity.Velocity
end
end)

userInputService.InputEnded:Connect(function(input, gameProcessedEvent)
if input.KeyCode == forward_key then
final_Vel = b_velocity.Velocity
holding = false
--b_velocity.Velocity = Vector3.new(0,0,0)

local deltaTime = GetDeltaTime()
local deltaVelocity = final_Vel - initial_Vel
local acceleration = deltaVelocity/deltaTime
local mass = hrp:GetMass()

local force = mass * acceleration
b_force.Force = force
print(force)
end
end)

function GetDeltaTime()
local current = tick()
return tick() - current
end
``````

Thanks for the help!

Giving the ball force will just give the ball more velocity unless you give it a force that is in the opposite direction there of the current velocities direction. Not only that but also what is slowing down the force too?

“…slowing down the force too?”
I think you mean: “…slowing down the force do?”
By using an opposite force, the ball will decrease in velocity (think of it as having some kind of friction), so the ball would stop eventually.

Thanks @Xx1Luffy1xX, I found the answer here:

Although the answer is for the unity game engine, it has similar physics. All I had to do was multiply the velocity a number smaller than one (but bigger than 0) such as 0.9. Then put it in a loop that stops when the velocity goes to zero, so the math doesn’t go forever.

``````        repeat
b_velocity.Velocity = b_velocity.Velocity * 0.9 --need to experiment to find the sweet spot
wait()
until b_velocity.Velocity == Vector3.new(0,0,0)
``````