I have scripted the car, but only the wheels turn and the car doesn’t actually move forwards. Code:
local function Update(DeltaTime)
local SteerGoal = -Seat.SteerFloat * MaxSteerAngle
Steer = Steer + (SteerGoal - Steer) * math.min(DeltaTime * Seat.TurnSpeed, 1)
AttachmentFL.Orientation = Vector3.new(0, Steer, -90)
AttachmentFR.Orientation = Vector3.new(0, Steer, -90)
if Driver.Name == "Truck" then
WheelBL.Orientation = Vector3.new(0, Steer, 0)
WheelBR.Orientation = Vector3.new(0, Steer, 0)
end
local ThrottleGoal = Seat.ThrottleFloat
Throttle = Throttle + (ThrottleGoal - Throttle) * math.min(DeltaTime * Seat.TurnSpeed, 1)
local Torque = Seat.Torque
local Speed = Seat.MaxSpeed * Throttle
CylindricalBL.MotorMaxTorque = Torque
CylindricalBR.MotorMaxTorque = Torque
CylindricalFL.MotorMaxTorque = Torque
CylindricalFR.MotorMaxTorque = Torque
CylindricalBL.AngularVelocity = Speed
CylindricalBR.AngularVelocity = -Speed
CylindricalFL.AngularVelocity = Speed
CylindricalFR.AngularVelocity = -Speed
end
The car with its constraints:
The place:
Place.rbxl (255.3 KB)