BodyVelocity getting back to normal after changed

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
  • I already achieved brakes for my airplane, but there’s a problem. The bodyvelocity will get back to normal once reduced.
  1. What is the issue? Include screenshots / videos if possible!

(sorry for bad quality)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
  • Yeah, nothing helped sadly.

Here’s the server-side code for the brakes. The airplane already has a bodyvelocity inside of the engine.

script.Parent.Parent.Events:WaitForChild("Brakes").OnServerEvent:Connect(function(client, state)
	local BodyForce = script.Parent.Parent:WaitForChild("MainParts"):WaitForChild("Engine"):FindFirstChild("BodyVelocity")

	BodyForce.Velocity = BodyForce.Velocity - script.Parent.Parent.MainParts.Engine.CFrame.LookVector * 1

I want to make it so once you brake, it stays at the reduced speed and doesn’t get back to normal.

In simulations like this you should have one “velocity” that is only ever added or subtracted from, not set. Its hard to say what to change without the rest of the code, but it looks like you probably have some other place that tracks speed, which takes back over after the brakes are released. Instead, that code should add velocity to the single place where velocity is tracked.

Yep, that’s the mistake i did. Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.