So I was making a car chassis with good physics and I completed the model of the car. Then I created a vehicle seat and put the following script inside:
-- get the specifications
local speed = script.speed.Value
local accleration = script.acceleration.Value
local steeringspeed = script.steeringSpeed.Value
local steeringangle = script.steeringAngle.Value
-- set up the shortcuts
local vehicle = script.Parent.Parent
local seat = script.Parent
-- find the tires
local A = vehicle.A -- front left
local AA = vehicle.AA -- front right
local B = vehicle.B -- back left
local BB = vehicle.BB -- back right
-- find the steering mechanism
local steerA = vehicle.SteeringA.Servo
local steerB = vehicle.SteeringB.Servo
-- set up wheels' motor accerlation
A.Motor.MotorMaxTorque = accleration
AA.Motor.MotorMaxTorque = accleration
B.Motor.MotorMaxTorque = accleration
BB.Motor.MotorMaxTorque = accleration
while true do
-- power the wheels
velocity = seat.Throttle * speed -- use the seat's throttle to determine the wheels' action (backward? forward? nothing?)
A.Motor.AngularVelocity = velocity
AA.Motor.AngularVelocity = velocity
B.Motor.AngularVelocity = -velocity
BB.Motor.AngularVelocity = -velocity
wait()
-- steering
steering = seat.Throttle * speed
steerA.AngularSpeed = steeringspeed
steerA.ServoMaxTorque = 100000000
steerA.TargetAngle = steeringangle*seat.Steer
steerB.AngularSpeed = steeringspeed
steerB.ServoMaxTorque = 100000000
steerB.TargetAngle = steeringangle*seat.Steer
end
What happens when I run the game is that the steering wheels turn the opposite direction when I turn right or left. This means that I cannot control the car!
The vehicle seat also has number values that represent the following from the above code:
local speed = script.speed.Value
local accleration = script.acceleration.Value
local steeringspeed = script.steeringSpeed.Value
local steeringangle = script.steeringAngle.Value

1 comment
Thank You SO MUCH! This helped, but for steerA, you don't have to put -1, cause it will do the same thing. Thanks Anyway!