Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Car steering opposite directions?

Asked by 5 years ago
Edited 5 years ago

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

01wait(1)
02SeatValue = script:WaitForChild("Seat")
03if 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
View all 35 lines...

SECOND SCRIPT (SERVER)

01while 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
0
did you edit it when it worked perfectly fine? 123nabilben123 499 — 5y
0
try swapping the left and right stuff? kom297 -4 — 5y
0
No I never edited it when it was fine, and yes I did try to swap but I probably didn't do it right. Pooglies 7 — 5y
0
Positive rotation goes counterclockwise; negative rotation goes clockwise. UHaveClout 1 — 5y
0
Well I have been testing it for a while now.Its weird, I was able to get it going the right way, but only if you have been driving like a second, otherwise it turns the wrong way. Also, if I turn it while not moving, the wheels will get all messed up when I start to drive and turn. Pooglies 7 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago

Try using this:

01if Base then
02    if Left then
03        leftMotor = Instance.new("Motor6D", car)
04        rightMotor.Name = "LeftMotor"
05        rightMotor.Part0 = Left
06        rightMotor.Part1 = Base
07        rightMotor.C0 = CFrame.new(-WheelSize/2-Left.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,-math.pi/2)
08        rightMotor.C1 = 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.Part0 = Right
15        leftMotor.Part1 = Base
16        leftMotor.C0 = CFrame.new(-WheelSize/2-Right.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
17        leftMotor.C1 = 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
20end
0
This just broke the car, I wish it worked Pooglies 7 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Hello. Try using elseif Right then.

01if Base then
02    if Left then
03        leftMotor = Instance.new("Motor6D", car)
04        leftMotor.Name = "LeftMotor"
05        leftMotor.Part0 = Left
06        leftMotor.Part1 = Base
07        leftMotor.C0 = CFrame.new(-WheelSize/2-Left.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,-math.pi/2)
08        leftMotor.C1 = 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.Part0 = Right
15        rightMotor.Part1 = Base
16        rightMotor.C0 = CFrame.new(-WheelSize/2-Right.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
17        rightMotor.C1 = 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
20end
0
This just breaks the car again, Idk how this even happend to be honest, how it can just switch amazes me. Pooglies 7 — 5y
0
Nevermind that comment, the end statements were messed up, I fixed them, the car was still messed up, but it flung after 2 seconds. Pooglies 7 — 5y
Log in to vote
0
Answered by 5 years ago

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.

Answer this question