So i made a space ship, which uses a script to find the Throttle
of a Vehicle Seat
...anyway i put a Part
called "Engine", with a BodyThrust
inside of it. So it works fine but, i cannot get it to stop, even if i anchor/unanchor the Ship, here is the script...How i can i fix it to make it stop when the throttle hits Zero???
01 | Seat = script.Parent.VehicleSeat |
02 | Engine = script.Parent.Engine |
03 |
04 | script.Parent.VehicleSeat.Changed:connect( function () |
05 | if script.Parent.VehicleSeat.Throttle = = 1 then |
06 | script.Parent.Engine.BodyThrust.Force = Vector 3. new( 0 , 0 ,- 9999110.09 ) --The Ship is really big so i need lots of Force to even move |
07 | end |
08 | end ) |
09 |
10 | script.Parent.VehicleSeat.Changed:connect( function () --This is the function where it should be stopping. |
11 | if script.Parent.VehicleSeat.Throttle = = 0 then |
12 | script.Parent.Engine.BodyThrust.Force = Vector 3. new( 0 , 0 , 0 ) --So how can i make the ship stop moving? |
13 | end |
14 | end ) |
15 |
16 | script.Parent.VehicleSeat.Changed:connect( function () |
17 | if script.Parent.VehicleSeat.Throttle = = - 1 then |
18 | script.Parent.Engine.BodyThrust.Force = Vector 3. new( 0 , 0 , 9999110.09 ) --The Ship is really big so i need lots of Force to even move |
19 | end |
20 | end ) |
Try this:
01 | Seat = script.Parent.VehicleSeat |
02 | Engine = script.Parent.Engine |
03 | BrakeSpeed = 10 --Change this to brake faster/slower |
04 | MoveSpeed = 9999110.09 --The Ship is really big so it needs lots of Force to even move |
05 |
06 | if not Engine:FindFirstChild( "BodyVelocity" ) then |
07 | BodyVelocity = Instance.new( "BodyVelocity" , Engine) |
08 | BodyVelocity.MaxForce = Vector 3. new( 0 , 0 , 0 ) |
09 | BodyVelocity.Velocity = Vector 3. new( 0 , 0 , 0 ) |
10 | else |
11 | BodyVelocity = Engine:FindFirstChild( "BodyVelocity" ) |
12 | end |
13 |
14 | script.Parent.VehicleSeat.Changed:connect( function () |
15 | if script.Parent.VehicleSeat.Throttle = = 1 then |