So I had a car that worked perfectly fine, and one day they randomly started turning the opposite direction than originally. This is the part of the script that controls that motor turning, any help?
after some more testing, I found that this was the script that controls this, this first script is full and is local, the 2nd script is server and is only part of the original script
01 | wait( 1 ) |
02 | SeatValue = script:WaitForChild( "Seat" ) |
03 | if SeatValue:IsA( "ObjectValue" ) and SeatValue.Value and SeatValue.Value:IsA( "VehicleSeat" ) then |
04 | seat = SeatValue.Value |
05 | car = seat.Parent |
06 | if seat:FindFirstChild( "RocketPropulsion" ) then |
07 | seat.RocketPropulsion:Fire() |
08 | end |
09 | local RemoteControlled = car:FindFirstChild( "ControlByRemote" ) |
10 | while seat:FindFirstChild( "SeatWeld" ) and RemoteControlled do |
11 | wait() |
12 | if not RemoteControlled:IsA( "VehicleSeat" ) then |
13 | break |
14 | end |
15 | RemoteControlled.Throttle = seat.Throttle |
SECOND SCRIPT (SERVER)
01 | while true do |
02 | for i = 1 , 60 do --60/30 == 2, 2 seconds between deciding if it's upside down |
03 | wait() -- we want the steering and sfx to update as many times a second as we can |
04 | if workspace.FilteringEnabled then |
05 | if car:FindFirstChild( "LeftMotor" ) then |
06 | car.LeftMotor.DesiredAngle = seat.Steer*math.rad( 60 -RemoteControlled.Velocity.magnitude/ 4 ) |
07 | end |
08 | if car:FindFirstChild( "RightMotor" ) then |
09 | car.RightMotor.DesiredAngle = seat.Steer*math.rad( 60 -RemoteControlled.Velocity.magnitude/ 4 ) |
10 | end |
11 | end |
Try using this:
01 | if Base then |
02 | if Left then |
03 | leftMotor = Instance.new( "Motor6D" , car) |
04 | rightMotor.Name = "LeftMotor" |
05 | rightMotor.Part 0 = Left |
06 | rightMotor.Part 1 = Base |
07 | rightMotor.C 0 = CFrame.new(-WheelSize/ 2 -Left.Size.x/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,-math.pi/ 2 ) |
08 | rightMotor.C 1 = CFrame.new(Base.Size.x/ 2 +Left.Size.x+WheelSize/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,math.pi/ 2 ) |
09 | rightMotor.MaxVelocity = motorSpeed |
10 | end |
11 | if Right then |
12 | = Instance.new( "Motor6D" , car) |
13 | leftMotor.Name = "RightMotor" |
14 | leftMotor.Part 0 = Right |
15 | leftMotor.Part 1 = Base |
16 | leftMotor.C 0 = CFrame.new(-WheelSize/ 2 -Right.Size.x/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,math.pi/ 2 ) |
17 | leftMotor.C 1 = CFrame.new(-Base.Size.x/ 2 -Right.Size.x-WheelSize/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,math.pi/ 2 ) |
18 | leftMotor.MaxVelocity = motorSpeed |
19 | end |
20 | end |
Hello. Try using elseif Right then
.
01 | if Base then |
02 | if Left then |
03 | leftMotor = Instance.new( "Motor6D" , car) |
04 | leftMotor.Name = "LeftMotor" |
05 | leftMotor.Part 0 = Left |
06 | leftMotor.Part 1 = Base |
07 | leftMotor.C 0 = CFrame.new(-WheelSize/ 2 -Left.Size.x/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,-math.pi/ 2 ) |
08 | leftMotor.C 1 = CFrame.new(Base.Size.x/ 2 +Left.Size.x+WheelSize/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,math.pi/ 2 ) |
09 | leftMotor.MaxVelocity = motorSpeed |
10 | end |
11 | elseif Right then |
12 | rightMotor = Instance.new( "Motor6D" , car) |
13 | rightMotor.Name = "RightMotor" |
14 | rightMotor.Part 0 = Right |
15 | rightMotor.Part 1 = Base |
16 | rightMotor.C 0 = CFrame.new(-WheelSize/ 2 -Right.Size.x/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,math.pi/ 2 ) |
17 | rightMotor.C 1 = CFrame.new(-Base.Size.x/ 2 -Right.Size.x-WheelSize/ 2 , 0 , 0 )*CFrame.Angles(math.pi/ 2 , 0 ,math.pi/ 2 ) |
18 | rightMotor.MaxVelocity = motorSpeed |
19 | end |
20 | end |
So basically, after a little research, I found out that roblox, FLIPPED, the motor6D and a bunch of things relating to that. So I just flipped the code a little bit. And it works.