BodyVelocity Stopping

Hello, I’m currently working on a project and I was wondering of the capabilities of putting a brick controlled by body velocity to a stop. How could I put the brick to a halt, deleting the bodyvelocity doesn’t work nor does setting all of it’s properties to 0. Are there any ways to achieve this?

1 Like

You can set the objects velocity to

Vector3.new()

Try anchoring it, then.

Try anchoring the part, Body Velocity is constant so deleting it won’t work.

Surely when i unanchor it, it will continue

Deleting the body velocity does work, I just tested it, if your creating it on the server ensure that you are destroying it on the server, and not from the client.

1 Like

Just set the velocity of the part to 0,0,0 after deleting bodyvelocity.

Part.Velocity = Vector3.new() -- this defaults as 0,0,0 I think

Setting the Parts Velocity to 0 will stop the part moving, but then resume straight after; shown in the gif.
https://gyazo.com/cc04b91e957d29a4c84d45d5b8003309

Setting the objects velocity to 0, will yes stop it moving however it doesn’t allow me to resume the bodyvelocity again

You can delete the BodyVelocity with a script and it’ll disable it.

This is the script I used to do this:

wait(10)
workspace.FlyingPart.BodyVelocity:Destroy()

So after 10 seconds the FlyingPart’s BodyVelocity will be destroyed :smiley:

Already tried this however, even after deleting it, the part will continue moving forwards.

Are you deleting it from a server script or a local script?

I’m removing it from a server script ofcourse.

You must have something else thats causing it then because I just tested it and deleting it does work.

You should keep track of the part youre attaching the BodyVelocity to while the game is running to make sure there’s only one. And if there is only one make sure it isn’t being added again after being destroyed.

1 Like

Ensure you don’t have another script that creates the body velocity when its destroyed.

1 Like

These are the lines related to the body velocity.

	if State == "holdingW" then
		if Ship.Middle:FindFirstChild("BodyVelocity") then
			Ship.Middle.BodyVelocity.maxForce = Vector3.new(2450,0,2450)
			Ship.Middle.BodyVelocity.Velocity =  Ship.Middle.CFrame.lookVector*-40*2
		else
			local BodyVelocity = Instance.new("BodyVelocity")
			BodyVelocity.Parent = Ship.Middle
			Ship.Middle.BodyVelocity.maxForce = Vector3.new(2450,0,2450)
			Ship.Middle.BodyVelocity.Velocity = Ship.Middle.CFrame.lookVector*-40*2
		end
	end
	if State == "notholdingW" then
		if Ship.Middle:FindFirstChild("BodyVelocity") then
			Ship.Middle.BodyVelocity:Destroy()
		end
	end

Try adding a print after “if Ship.Middle:FindFirstChild(“BodyVelocity”) then” to make sure it finds the BodyVelocity. If the print works and the BodyVelocity is found then go to the Explorer and find where its parented and see if only one is being created.

I’ve done that already, the code is completely fine, function-wise.

I don’t really know what the problem is, but I can tell you to use functions to organize the way your scripts work. They’re useful for figuring out why something like this is happening, and easier to read.

Also I think instead of setting the Velocity to () you should set it to “speed” and when you press let’s say S speed = 0, then when your velocity is moving * speed it will stop moving. You really should use functions for this though, like “UpdateVelocity” rather than using an if statement, because sometimes one if statement can overlap another causing it to not work the way you planned it to.

I’m aware functions would be more organised however, this is just an alpha test, as I said above, functioning-wise the code is fine, nothing breaks, nothing happens that it shouldn’t. My only problem is removing the BodyVelocity doesn’t stop the Part from actually moving.