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 4 years ago
Edited 4 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

wait(1)
SeatValue = script:WaitForChild("Seat")
if SeatValue:IsA("ObjectValue") and SeatValue.Value and SeatValue.Value:IsA("VehicleSeat") then
    seat = SeatValue.Value
    car = seat.Parent
    if seat:FindFirstChild("RocketPropulsion") then
        seat.RocketPropulsion:Fire()
    end
    local RemoteControlled = car:FindFirstChild("ControlByRemote")
    while seat:FindFirstChild("SeatWeld") and RemoteControlled do
        wait()
        if not RemoteControlled:IsA("VehicleSeat") then
            break
        end
        RemoteControlled.Throttle = seat.Throttle
        if car:FindFirstChild("LeftMotor") then
            car.LeftMotor.DesiredAngle = seat.Steer*math.rad(30-RemoteControlled.Velocity.magnitude/4)
        end
        if car:FindFirstChild("RightMotor") then
            car.RightMotor.DesiredAngle = seat.Steer*math.rad(30-RemoteControlled.Velocity.magnitude/4)
        end
        if car:FindFirstChild("Configuration") then
            if seat.Throttle == 1 and car.Configuration:FindFirstChild("Forwards Speed") then
                RemoteControlled.MaxSpeed = car.Configuration["Forwards Speed"].Value
            elseif seat.Throttle == 0 then
                RemoteControlled.MaxSpeed = 0
            elseif seat.Throttle == -1 and car.Configuration:FindFirstChild("Reverse Speed") then
                RemoteControlled.MaxSpeed = car.Configuration["Reverse Speed"].Value
            end
        end
    end
    if seat:FindFirstChild("RocketPropulsion") then
        seat.RocketPropulsion:Abort()
    end
end

SECOND SCRIPT (SERVER)

while true do
    for i = 1, 60 do--60/30 == 2, 2 seconds between deciding if it's upside down
        wait()-- we want the steering and sfx to update as many times a second as we can
        if workspace.FilteringEnabled then
            if car:FindFirstChild("LeftMotor") then
                car.LeftMotor.DesiredAngle = seat.Steer*math.rad(60-RemoteControlled.Velocity.magnitude/4)
            end
            if car:FindFirstChild("RightMotor") then
                car.RightMotor.DesiredAngle = seat.Steer*math.rad(60-RemoteControlled.Velocity.magnitude/4)
            end
        end
0
did you edit it when it worked perfectly fine? 123nabilben123 499 — 4y
0
try swapping the left and right stuff? kom297 -4 — 4y
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 — 4y
0
Positive rotation goes counterclockwise; negative rotation goes clockwise. UHaveClout 1 — 4y
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 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

Try using this:

 if Base then
    if Left then
        leftMotor = Instance.new("Motor6D", car)
        rightMotor.Name = "LeftMotor"
        rightMotor.Part0 = Left
        rightMotor.Part1 = Base
        rightMotor.C0 = CFrame.new(-WheelSize/2-Left.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,-math.pi/2)
        rightMotor.C1 = CFrame.new(Base.Size.x/2+Left.Size.x+WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
        rightMotor.MaxVelocity = motorSpeed
    end
    if Right then
         = Instance.new("Motor6D", car)
        leftMotor.Name = "RightMotor"
        leftMotor.Part0 = Right
        leftMotor.Part1 = Base
        leftMotor.C0 = CFrame.new(-WheelSize/2-Right.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
        leftMotor.C1 = CFrame.new(-Base.Size.x/2-Right.Size.x-WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
        leftMotor.MaxVelocity = motorSpeed
    end
end

0
This just broke the car, I wish it worked Pooglies 7 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Hello. Try using elseif Right then.

if Base then
    if Left then
        leftMotor = Instance.new("Motor6D", car)
        leftMotor.Name = "LeftMotor"
        leftMotor.Part0 = Left
        leftMotor.Part1 = Base
        leftMotor.C0 = CFrame.new(-WheelSize/2-Left.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,-math.pi/2)
        leftMotor.C1 = CFrame.new(Base.Size.x/2+Left.Size.x+WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
        leftMotor.MaxVelocity = motorSpeed
    end
   elseif Right then
        rightMotor = Instance.new("Motor6D", car)
        rightMotor.Name = "RightMotor"
        rightMotor.Part0 = Right
        rightMotor.Part1 = Base
        rightMotor.C0 = CFrame.new(-WheelSize/2-Right.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
        rightMotor.C1 = CFrame.new(-Base.Size.x/2-Right.Size.x-WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)
        rightMotor.MaxVelocity = motorSpeed
    end
end
0
This just breaks the car again, Idk how this even happend to be honest, how it can just switch amazes me. Pooglies 7 — 4y
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 — 4y
Log in to vote
0
Answered by 4 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