Advertisement
TheUnknownDiscord

car ai testing

Oct 15th, 2021 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. script.Parent = owner.Character
  2. Seat = Instance.new("VehicleSeat")
  3. Seat.Parent = script
  4. Seat.Size = Vector3.new(4,1,10)
  5. Seat.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(0,8,-8.057)
  6. Seat.TopSurface = Enum.SurfaceType.Smooth
  7. Seat.BottomSurface = Enum.SurfaceType.Smooth
  8. Bumper = Instance.new("Part")
  9. Bumper.Parent = script
  10. Bumper.Size = Vector3.new(7.75,2.25,1)
  11. Weldlol3 = Instance.new("Weld")
  12. Weldlol3.Parent = Seat
  13. Weldlol3.Part0 = Seat
  14. Weldlol3.Part1 = Bumper
  15. Weldlol3.C1 = Weldlol3.C1 * CFrame.new(0,-1.25,9.75)
  16. side = Instance.new("Part")
  17. side.Parent = script
  18. side.Size = Vector3.new(1.75,0.25,17.15)
  19. Weldside = Instance.new("Weld")
  20. Weldside.Parent = Seat
  21. Weldside.Part0 = Seat
  22. Weldside.Part1 = side
  23. Weldside.C1 = Weldside.C1 * CFrame.new(3.0625,-2.25,0.625)
  24. side2 = Instance.new("Part")
  25. side2.Parent = script
  26. side2.Size = Vector3.new(1.75,0.25,17.15)
  27. Weldside2 = Instance.new("Weld")
  28. Weldside2.Parent = Seat
  29. Weldside2.Part0 = Seat
  30. Weldside2.Part1 = side2
  31. Weldside2.C1 = Weldside2.C1 * CFrame.new(-3.0625,-2.25,0.625)
  32. Bumper3 = Instance.new("Part")
  33. Bumper3.Parent = script
  34. Bumper3.Size = Vector3.new(4,2.25,4.65)
  35. Weldlol32 = Instance.new("Weld")
  36. Weldlol32.Parent = Bumper
  37. Weldlol32.Part0 = Bumper
  38. Weldlol32.Part1 = Bumper3
  39. Weldlol32.C1 = Weldlol32.C1 * CFrame.new(0,0,-2.5)
  40. Bumper2 = Instance.new("Part")
  41. Bumper2.Parent = script
  42. Bumper2.Size = Vector3.new(7.75,2.25,1)
  43. Weldlol31 = Instance.new("Weld")
  44. Weldlol31.Parent = Seat
  45. Weldlol31.Part0 = Seat
  46. Weldlol31.Part1 = Bumper2
  47. Weldlol31.C1 = Weldlol31.C1 * CFrame.new(0,-1.25,-8.5)
  48. Bumper4 = Instance.new("Part")
  49. Bumper4.Parent = script
  50. Bumper4.Size = Vector3.new(4,2.25,4.65)
  51. Weldlol33 = Instance.new("Weld")
  52. Weldlol33.Parent = Bumper2
  53. Weldlol33.Part0 = Bumper2
  54. Weldlol33.Part1 = Bumper4
  55. Weldlol33.C1 = Weldlol33.C1 * CFrame.new(0,0,2.5)
  56. wheel = Instance.new("Part")
  57. wheel.Parent = Seat
  58. wheel.Size = Vector3.new(1,3,3)
  59. steer = Instance.new("Part")
  60. steer.Parent = Seat
  61. steer.Size = Vector3.new(1,1,1)
  62. steer2 = Instance.new("Part")
  63. steer2.Parent = Seat
  64. steer2.Size = Vector3.new(1,1,1)
  65. steer.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(-3.739,1,-7.25)
  66. steer2.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(3.739,1,-7.25)
  67. steer.Transparency = 1
  68. steer.CanCollide = false
  69. steer2.Transparency = 1
  70. steer2.CanCollide = false
  71. Seat.Anchored = true
  72. wheel.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(-3.739,6.5,-7.25)
  73. wheel.TopSurface = Enum.SurfaceType.Smooth
  74. wheel.BottomSurface = Enum.SurfaceType.Smooth
  75. wheel2 = Instance.new("Part")
  76. wheel2.Parent = Seat
  77. wheel2.Size = Vector3.new(1,3,3)
  78. wheel2.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(3.739,6.5,-7.25)
  79. wheel2.TopSurface = Enum.SurfaceType.Smooth
  80. wheel2.BottomSurface = Enum.SurfaceType.Smooth
  81. wheel3 = Instance.new("Part")
  82. wheel3.Parent = Seat
  83. wheel3.Size = Vector3.new(1,3,3)
  84. wheel3.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(-3.739,6.5,5.75)
  85. wheel3.TopSurface = Enum.SurfaceType.Smooth
  86. wheel3.BottomSurface = Enum.SurfaceType.Smooth
  87. wheel4 = Instance.new("Part")
  88. wheel4.Parent = Seat
  89. wheel4.Size = Vector3.new(1,3,3)
  90. wheel4.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(3.739,6.5,5.75)
  91. wheel4.TopSurface = Enum.SurfaceType.Smooth
  92. wheel4.BottomSurface = Enum.SurfaceType.Smooth
  93. wheel.Shape = Enum.PartType.Cylinder
  94. wheel2.Shape = Enum.PartType.Cylinder
  95. wheel3.Shape = Enum.PartType.Cylinder
  96. wheel4.Shape = Enum.PartType.Cylinder
  97. local attachment0 = Instance.new("Attachment")
  98. attachment0.Parent = steer
  99. local attachment1 = Instance.new("Attachment")
  100. attachment1.Parent = Seat
  101. alignposition = Instance.new("HingeConstraint")
  102. alignposition.Parent = Seat
  103. alignposition.ActuatorType = "Servo"
  104. alignposition.TargetAngle = 0
  105. alignposition.Name = "Hinge4"
  106. alignposition.ServoMaxTorque = 10000000
  107. alignposition.AngularSpeed = 10000000
  108. alignposition.Attachment0 = attachment0
  109. alignposition.Attachment1 = attachment1
  110. attachment1.WorldCFrame = attachment1.Parent.CFrame * CFrame.new(-3.739,1,-7.25) * CFrame.Angles(0,math.rad(180),math.rad(90))
  111. local attachment02 = Instance.new("Attachment")
  112. attachment02.Parent = steer2
  113. local attachment12 = Instance.new("Attachment")
  114. attachment12.Parent = Seat
  115. alignposition2 = Instance.new("HingeConstraint")
  116. alignposition2.Parent = Seat
  117. alignposition2.ActuatorType = "Servo"
  118. alignposition2.TargetAngle = 0
  119. alignposition2.Name = "Hinge3"
  120. alignposition2.ServoMaxTorque = 10000000
  121. alignposition2.AngularSpeed = 10000000
  122. alignposition2.Attachment0 = attachment02
  123. alignposition2.Attachment1 = attachment12
  124. attachment12.WorldCFrame = attachment12.Parent.CFrame * CFrame.new(3.739,1,-7.25) * CFrame.Angles(0,0,math.rad(90))
  125. task.wait()
  126. local attachment031 = Instance.new("Attachment")
  127. attachment031.Parent = wheel
  128. local attachment131 = Instance.new("Attachment")
  129. attachment131.Parent = steer
  130. alignposition31 = Instance.new("HingeConstraint")
  131. alignposition31.Parent = Seat
  132. alignposition31.ActuatorType = Enum.ActuatorType.None
  133. alignposition31.Attachment0 = attachment031
  134. alignposition31.Attachment1 = attachment131
  135. attachment131.WorldCFrame = attachment131.Parent.CFrame * CFrame.new(-1,0,0) * CFrame.Angles(0,0,math.rad(-90))
  136. local attachment0231 = Instance.new("Attachment")
  137. attachment0231.Parent = wheel2
  138. local attachment1231 = Instance.new("Attachment")
  139. attachment1231.Parent = steer2
  140. alignposition231 = Instance.new("HingeConstraint")
  141. alignposition231.Parent = Seat
  142. alignposition231.ActuatorType = Enum.ActuatorType.None
  143. alignposition231.Attachment0 = attachment0231
  144. alignposition231.Attachment1 = attachment1231
  145. attachment1231.WorldCFrame = attachment1231.Parent.CFrame * CFrame.new(-1,0,0) * CFrame.Angles(0,0,math.rad(-90))
  146. local attachment03 = Instance.new("Attachment")
  147. attachment03.Parent = wheel3
  148. local attachment13 = Instance.new("Attachment")
  149. attachment13.Parent = Seat
  150. alignposition3 = Instance.new("HingeConstraint")
  151. alignposition3.Parent = Seat
  152. alignposition3.ActuatorType = "Motor"
  153. alignposition3.MotorMaxAcceleration = 10000000
  154. alignposition3.MotorMaxTorque = 10000000
  155. alignposition3.Name = "Hinge1"
  156. alignposition3.Attachment0 = attachment03
  157. alignposition3.Attachment1 = attachment13
  158. attachment13.WorldCFrame = attachment13.Parent.CFrame * CFrame.new(-3.739,0,5.75)* CFrame.Angles(0,math.rad(180),0)
  159. local attachment023 = Instance.new("Attachment")
  160. attachment023.Parent = wheel4
  161. local attachment123 = Instance.new("Attachment")
  162. attachment123.Parent = Seat
  163. alignposition23 = Instance.new("HingeConstraint")
  164. alignposition23.Parent = Seat
  165. alignposition23.ActuatorType = "Motor"
  166. alignposition23.MotorMaxAcceleration = 10000000
  167. alignposition23.MotorMaxTorque = 10000000
  168. alignposition23.Name = "Hinge2"
  169. alignposition23.Attachment0 = attachment023
  170. alignposition23.Attachment1 = attachment123
  171. attachment123.WorldCFrame = attachment123.Parent.CFrame * CFrame.new(3.739,0,5.75)
  172. local motor1 = alignposition3
  173. local motor2 = alignposition23
  174. local steerServo = alignposition
  175. local steerServo2 = alignposition2
  176. local maxSpeed = 20
  177. local angleSteer = 27.5
  178. local density = 1
  179. local friction = 1
  180. local elasticity = 0
  181. local frictionWeight = 100000000000
  182. local elasticityWeight = 0
  183. local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
  184. Seat.CustomPhysicalProperties = physProperties
  185. wheel.CustomPhysicalProperties = physProperties
  186. wheel2.CustomPhysicalProperties = physProperties
  187. wheel3.CustomPhysicalProperties = physProperties
  188. wheel4.CustomPhysicalProperties = physProperties
  189. Part1 = Instance.new("Part")
  190. Part1.Anchored = true
  191. Part1.Position = Vector3.new(math.random(-50,50),0,math.random(-50,50))
  192. wait(0.25)
  193. Seat.Anchored = false
  194.  
  195. local PathfindingService = game:GetService("PathfindingService")
  196. local destination = Part1
  197.  
  198. local maxSpeed = 20
  199. local angleSteer = 27.5
  200. local path = PathfindingService:CreatePath()
  201.  
  202. path:ComputeAsync(Seat.Position, destination.Position)
  203.  
  204. local waypoints = path:GetWaypoints()
  205.  
  206. for _, waypoint in pairs(waypoints) do
  207. bumpp = Bumper.Position
  208. wayp = waypoint.Position
  209. local part = Instance.new("Part")
  210. part.Shape = "Ball"
  211. part.Material = "Neon"
  212. part.Size = Vector3.new(0.6, 0.6, 0.6)
  213. part.Position = waypoint.Position
  214. part.Anchored = true
  215. part.CanCollide = false
  216. part.Parent = script
  217. alignposition23.AngularVelocity = 1 * maxSpeed
  218. alignposition3.AngularVelocity = 1 * -maxSpeed
  219. alignposition.TargetAngle = CFrame.lookAt(bumpp, wayp)
  220. alignposition2.TargetAngle = CFrame.lookAt(bumpp, wayp)
  221. wait(1)
  222. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement