BodyVelocity Question

  1. What do you want to achieve? I want to make a railway simulator similar to for example SCR or Steamlined.

  2. What is the issue? I am getting this error when trying to change the Velocity of a Body Velocity.
    image

  3. What solutions have you tried so far? I have tried to change the MaxForce aswell, but the same error appeared.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent.FrontWheel then
		hit.Parent.FrontWheel.BodyVelocity.Velocity.Z = 0
	end
end)

How can I set the BodyVelocity to 0 when a part of the train hits this part?

You can’t write to a single value of a Vector3, you have to write it as another Vector3. In this case we can simplify it by taking the original Velocity and multiplying it by a Vector3 of 1,1,0.

hit.Parent.FrontWheel.BodyVelocity.Velocity *= Vector3.new(1,1,0)
2 Likes

I am still getting the same error when my code is exactly like you said.

Made a typo in the original code, I’ve edited my reply, try using that?

It does work now! Thanks for your help!