Help with removing a part velocity

so i have a mesh part in my game and when a player touches it a body velocity will appear in the part and make the part move and the instantly delete the body velocity but the problem is once it touch another part i want it teleport to a place no the problem is even after teleporting the ball still has velocity and moves around but i dont want it as i want it to be stationary after teleporting i dont want to anchor it as i want physics but i still wanna make the part stationary any idea how to remove all velocity and make the part stationary?

May I see your code to get a better understanding of what the problem is?

From what I read, I can only tell you that u can use a for loop to iterate through the part and find the BodyVelocity and delete it.

Another possible problem that I guessed is that more than one BodyVelocity was cloned when touch event was activated.

But either way, u can try iterating through the part to find and destroy all BodyVelocity / find that specific BodyVelocity and destroy it.

Ex.

for i,v in pairs (part:GetChildren()) do
    if v:FindFirstChild("name of your BodyVelocity") then
        v:Destroy()
    end
end

well my code is just basically a soccer ball code where i have a touched function

ball.Touched:Connect(function(hit)
   local bodyvel = Instance.new("BodyVelocity",ball)
   bodyvel.Velocity = hit.LookVector*10
   wait(.1)
   bodyvel:Destroy()
end)

You can use the physics functions to stop the ball. Here is some code:

local function resetVelocity(part)
    part:ApplyImpluse(part.AssemblyLinearVelocity * part.AssemblyMass * -1)
    part:ApplyAngularImpulse(part.AssemblyAngularVelocity * part.AssemblyMass * -1)
end
1 Like

ok ill try it out and tell you about it

Try doing:

wait(.1)
for i,v in pairs (ball:GetChildren()) do
    if v.ClassName == ("BodyVelocity") then
        v:Destroy()
    end
end

its not about body velocity its about that the ball still rolling but i dont want it to

I see, so u want the ball to completely stop without anchoring it? How about BodyPosition?

basically once player scrores the ball into goal i want the ball to tp to the middle of field and then be stationary instead it still rolls around

Why not just

ball.Velocity = Vector3.new(0, 0, 0)

?

tried that but didnt work it gave me an error Velocity is not a member of ball

Then set the Position of the ball to the area u want it to tp and add new instance for BodyPosition that’s what I think u can do.

Maybe

ball.AssemblyLinearVelocity = Vector3.new(0, 0, 0)

instead?

still no it doesnt work ```

Try not putting a BodyVelocity into the ball and destroying it.

Instead just set AssemblyLinearVelocity to the LookVector.

Maybe the BV is sticking around too long.

i dont think the body velocity is actually being for too long

thanks everybody but i fixed it by cloning a new ball every time a person scores instead of using the same ball

1 Like