So I have a car that worked perfectly fine and then started turning the opposite direction than it was originally. I messed with this a little but it never worked the same again, any help?
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
if 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
So after a long time of testing, I was able to see that the code that I provided, did not control the vehicle steering, these 2 scripts do, and I was able to edit these to the best of my ability to make them work, but for some reason, unless the car is moving, the steering is still going the wrong directions, but if I am moving, it goes correctly, and with that, if im turning my wheels, go forward, and turn more, the wheels go weird and the car stops working (until you let go then it fixes itself)
The entire local 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 --- Where the turning part is
if car:FindFirstChild("LeftMotor") then
print("left motor")
car.LeftMotor.DesiredAngle = seat.Steer/math.rad(80-RemoteControlled.Velocity.magnitude*6)
end
if car:FindFirstChild("RightMotor") then
print("right motor")
car.RightMotor.DesiredAngle = seat.Steer/math.rad(80-RemoteControlled.Velocity.magnitude*6)
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
SERVER SCRIPT (ONLY PART OF IT)
while true do
for i = 1, 60 do
wait()
if workspace.FilteringEnabled then
if car:FindFirstChild("LeftMotor") then
if seat.Throttle ~= 0 then
car.LeftMotor.DesiredAngle = seat.Steer/math.rad(80-RemoteControlled.Velocity.magnitude*6)
print(seat.Steer/math.rad(80-RemoteControlled.Velocity.magnitude*6))
end
if car:FindFirstChild("RightMotor") then
if seat.Throttle ~= 0 then
car.RightMotor.DesiredAngle = seat.Steer/math.rad(80-RemoteControlled.Velocity.magnitude*6)
print(seat.Steer/math.rad(80-RemoteControlled.Velocity.magnitude*6))
end
end
end
end
I just inserted the Motorcycle free model, and it seems to be working fine, so is it a roblox bug? I did try with the sedan and it was broken, but it could just be the code?
So I have a car that worked perfectly fine and then started turning the opposite direction than it was originally.
I think this is because of the changes that happened to Motor6Ds. Snippet from the devforum post:
in models that you rigged yourself or with third-party tools and happen to be using Motor6Ds “backwards”, your game may be affected. Soon they will be not-backwards, which might mean “backwards” for you.