Advertisement
Hasli4

RBLX. QuadroScript

May 15th, 2025
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. local QuadBike = script.Parent
  2. local vehicleSeat = QuadBike.VehicleSeat
  3. local rear_axle = QuadBike.rear_axle
  4. local front_axle = QuadBike.front_axle
  5.  
  6. local MotorLB = rear_axle.wheel_axle.CylindricalConstraint_l
  7. local MotorRB = rear_axle.wheel_axle.CylindricalConstraint_r
  8.  
  9. local MotorLF = front_axle.wheel_axle.CylindricalConstraint_l
  10. local MotorRF = front_axle.wheel_axle.CylindricalConstraint_r
  11.  
  12. local MaxSpeed = vehicleSeat.MaxSpeed
  13. local currentVelocity = vehicleSeat.AssemblyLinearVelocity
  14. local torqueMax = 1000000
  15. local RotateVel = 50
  16.  
  17. MotorLB.MotorMaxTorque = torqueMax
  18. MotorRB.MotorMaxTorque = torqueMax
  19. MotorLF.MotorMaxTorque = torqueMax
  20. MotorRF.MotorMaxTorque = torqueMax
  21.  
  22. local function setMotorVelocity(vel)
  23.     MotorLF.AngularVelocity = vel
  24.     MotorLB.AngularVelocity = vel
  25.     -- Моторы с правой стороны должны вращать
  26. -- колёса по часовой стрелки, а слева - против
  27.     MotorRF.AngularVelocity = -vel
  28.     MotorRB.AngularVelocity = -vel
  29. end
  30. while true do
  31.    
  32.     -- Проверка ввода при помощи vehicleSeat
  33.     local steerFloat = vehicleSeat.SteerFloat
  34.     -- Вперёд и назад, значение от -1 до 1
  35.     local throttle = vehicleSeat.ThrottleFloat
  36.     -- Влево и вправо, значение от -1 до 1
  37.  
  38.     if steerFloat == 0 then
  39.         if throttle ~= 0 then
  40.             setMotorVelocity(throttle * RotateVel)
  41.         end
  42.         if throttle == 0 then
  43.             setMotorVelocity(0)
  44.         end
  45.     end
  46.  
  47.         if steerFloat < 0 then
  48.         MotorLB.AngularVelocity = -0.7*RotateVel
  49.         MotorRB.AngularVelocity = -RotateVel
  50.         MotorLF.AngularVelocity = -0.7*RotateVel
  51.         MotorRF.AngularVelocity = -RotateVel
  52.         wait()
  53.     end
  54.          if steerFloat > 0 then
  55.               MotorLB.AngularVelocity = RotateVel
  56.               MotorRB.AngularVelocity = 0.7*RotateVel
  57.               MotorLF.AngularVelocity = RotateVel
  58.               MotorRF.AngularVelocity = 0.7*RotateVel
  59.               wait()
  60.         end
  61.     if vehicleSeat.Orientation.Z > 90 or vehicleSeat.Orientation.Z < -90 then
  62.         wait(1)
  63.         vehicleSeat.CFrame = CFrame.new(vehicleSeat.Position) *
  64. CFrame.Angles(0, vehicleSeat.Orientation.Y, 0)
  65.     end
  66.  
  67.     wait()
  68. end
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement
OSZAR »