Advertisement
Guest User

Car Script

a guest
Dec 3rd, 2021
21,328
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 1 0
  1. local seat = script.Parent.VehicleSeat
  2.  
  3. local backLeft = script.Parent.BackLeft
  4. local backRight = script.Parent.BackRight
  5.  
  6. local frontLeft = script.Parent.FrontLeft
  7. local frontRight = script.Parent.FrontRight
  8.  
  9. local steerAngle = 30
  10. local speed = 60
  11.  
  12. seat:GetPropertyChangedSignal("Steer"):Connect(function()
  13.     frontLeft.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.Steer
  14.     frontRight.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.Steer
  15. end)
  16.  
  17. seat:GetPropertyChangedSignal("Throttle"):Connect(function()
  18.     frontLeft.Wheel.WheelConstraint.AngularVelocity = speed * seat.Throttle
  19.     frontRight.Wheel.WheelConstraint.AngularVelocity = speed * -seat.Throttle
  20.    
  21.     backLeft.Wheel.WheelConstraint.AngularVelocity = speed * seat.Throttle
  22.     backRight.Wheel.WheelConstraint.AngularVelocity = speed * -seat.Throttle
  23. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement