Advertisement
TheUnknownDiscord

car

Mar 29th, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.10 KB | None | 0 0
  1. function suspension(what,cf,mot)
  2. local a = Instance.new("Part", script)
  3. local a2 = Instance.new("Part", script)
  4. local a3 = Instance.new("Part", script)
  5. a2.Name = "the"
  6. a3.Name = "the"
  7. a.Name = "the"
  8. local density = 8
  9. local friction = 1.5
  10. local elasticity = 0
  11. local frictionWeight = 10
  12. local elasticityWeight = 100000
  13. local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
  14. a2.CustomPhysicalProperties = physProperties
  15. a.Size = Vector3.new(1,1,1)
  16. a2.Size = Vector3.new(1.125,3,3)
  17. a2.Shape = "Cylinder"
  18. a2.Material = "SmoothPlastic"
  19. a3.Size = Vector3.new(0.125,1.75,1.75)
  20. a3.Shape = "Cylinder"
  21. a3.Material = "SmoothPlastic"
  22. a2.Color = Color3.fromRGB(30,30,30)
  23. local weld = Instance.new("Weld",a2)
  24. weld.Part0 = a3
  25. weld.Part1 = a2
  26. weld.C0 = CFrame.new(-0.55,0,0)
  27. a.CFrame = what.CFrame * cf:Inverse()
  28. a.Anchored = true
  29. a2.CFrame = what.CFrame * cf:Inverse() * CFrame.new(1,0,0)
  30. a2.Anchored = true
  31. a.Transparency = 1
  32. a.CanCollide = false
  33. local at0 = Instance.new("Attachment" , a)
  34. at0.CFrame = CFrame.new(2,-1,0) * CFrame.Angles(0,0,math.rad(-90))
  35. local at1 = Instance.new("Attachment" , a2)
  36. local at2 = Instance.new("Attachment" , a)
  37. at2.CFrame = CFrame.Angles(0,0,math.rad(-90)) * CFrame.new(-1,0,0)
  38. local prism = Instance.new("CylindricalConstraint" , a)
  39. prism.Attachment0 = at0
  40. prism.InclinationAngle = 90
  41. prism.Attachment1 = at1
  42. prism.LimitsEnabled = true
  43. prism.LowerLimit = -1.5
  44. prism.UpperLimit = 1.5
  45. prism.Restitution = 0
  46. local spring = Instance.new("SpringConstraint" , a)
  47. spring.Attachment0 = at1
  48. spring.Attachment1 = at2
  49. spring.Stiffness = 30000
  50. spring.FreeLength = 2.2
  51. spring.Enabled = true
  52. spring.Damping = 400
  53. if mot then
  54. prism.AngularActuatorType = "Motor"
  55. prism.MotorMaxAngularAcceleration = 1000
  56. prism.MotorMaxTorque = math.huge
  57. end
  58. wait()
  59. a2.Anchored = false
  60. a.Anchored = false
  61. local wel = Instance.new("Weld",what)
  62. wel.Part0 = a
  63. wel.Part1 = what
  64. wel.C0 = cf
  65. return prism
  66. end
  67. part = Instance.new("VehicleSeat",script)
  68. trail = Instance.new("Part",script)
  69. local sound = Instance.new("Sound",part)
  70. sound.Looped = true
  71. sound.Volume = 3
  72. sound.SoundId = "rbxassetid://9112787518"
  73. sound:Play()
  74. part.Size = Vector3.new(3,1,11)
  75. trail.Size = Vector3.new(7,1,13)
  76. trail.Anchored = true
  77. part.CFrame = owner.Character.Head.CFrame * CFrame.new(0,0,-5)
  78. trail.CFrame = owner.Character.Head.CFrame * CFrame.new(0,0,5)
  79. trail.Material = "SmoothPlastic"
  80. part.Anchored = true
  81. local part4 = Instance.new("Part",part)
  82. part4.Size = Vector3.new(3,1,0.25)
  83. part.Material = "SmoothPlastic"
  84. part4.Material = "SmoothPlastic"
  85. local part5 = Instance.new("Part",part)
  86. part5.Size = Vector3.new(2,2.5,0.5)
  87. part5.Material = "SmoothPlastic"
  88. local part6 = Instance.new("Part",part)
  89. part6.Size = Vector3.new(2.05,2.55,0.45)
  90. part6.Material = "SmoothPlastic"
  91. local part7 = Instance.new("Part",part)
  92. part7.Size = Vector3.new(1.75,1,0.125)
  93. part7.Material = "SmoothPlastic"
  94. part5.Color = Color3.fromRGB(122, 85, 4)
  95. local wel = Instance.new("Weld",part)
  96. wel.Part0 = part4
  97. wel.Part1 = part
  98. wel.C0 = CFrame.new(0,0,5.5)
  99. local wel2 = Instance.new("Weld",part)
  100. wel2.Part0 = part5
  101. wel2.Part1 = part
  102. wel2.C0 = CFrame.new(0,-1.75,-1) * CFrame.Angles(math.rad(-15),0,0)
  103. local wel3 = Instance.new("Weld",part)
  104. wel3.Part0 = part6
  105. wel3.Part1 = part
  106. wel3.C0 = CFrame.new(0,-1.75,-1.075) * CFrame.Angles(math.rad(-15),0,0)
  107. local wel4 = Instance.new("Weld",part)
  108. wel4.Part0 = part7
  109. wel4.Part1 = part
  110. wel4.C1 = CFrame.new(0,2.5,-2) * CFrame.Angles(math.rad(-10),0,0)
  111. part2 = Instance.new("Part",part)
  112. part2.CanCollide = false
  113. part2.Transparency = 1
  114. local ats = Instance.new("Attachment",part)
  115. ats.CFrame = CFrame.new(1.25,0,-3.825) * CFrame.Angles(0,0,math.rad(90))
  116. local ats2 = Instance.new("Attachment",part2)
  117. ats2.CFrame = CFrame.new(0,1,0) * CFrame.Angles(0,0,math.rad(90))
  118. part2.CFrame = part.CFrame * ats.CFrame
  119. steer = Instance.new("HingeConstraint")
  120. steer.Parent = part
  121. steer.ActuatorType = "Servo"
  122. steer.TargetAngle = 0
  123. steer.ServoMaxTorque = 10000000000000000
  124. steer.AngularSpeed = 100000000000000
  125. steer.Attachment0 = ats
  126. steer.Attachment1 = ats2
  127. part3 = Instance.new("Part",part)
  128. part3.CanCollide = false
  129. part3.Transparency = 1
  130. local ats3 = Instance.new("Attachment",part)
  131. ats3.CFrame = CFrame.new(-1.25,0,-3.825) * CFrame.Angles(0,0,math.rad(90))
  132. local ats4 = Instance.new("Attachment",part3)
  133. ats4.CFrame = CFrame.new(0,1,0) * CFrame.Angles(0,0,math.rad(90))
  134. part3.CFrame = part.CFrame * ats3.CFrame
  135. steer2 = Instance.new("HingeConstraint")
  136. steer2.Parent = part
  137. steer2.ActuatorType = "Servo"
  138. steer2.TargetAngle = 0
  139. steer2.ServoMaxTorque = 10000000000000000
  140. steer2.AngularSpeed = 100000000000000
  141. steer2.Attachment0 = ats3
  142. steer2.Attachment1 = ats4
  143. local trailer = Instance.new("BallSocketConstraint",part)
  144. function seat(cf1,cf2,cf3)
  145. local part10 = Instance.new("Seat",trail)
  146. part10.Size = Vector3.new(3,0.5,1.5)
  147. part10.Material = "SmoothPlastic"
  148. local part11 = Instance.new("Part",trail)
  149. part11.Size = Vector3.new(3.05,0.5,1.55)
  150. part11.Material = "SmoothPlastic"
  151. part10.Color = Color3.fromRGB(122, 85, 4)
  152. local wel7 = Instance.new("Weld",trail)
  153. wel7.Part0 = part10
  154. wel7.Part1 = trail
  155. wel7.C0 = CFrame.new(-cf3,-0.5,-cf1) * CFrame.Angles(0,math.rad(cf2),0)
  156. local wel8 = Instance.new("Weld",trail)
  157. wel8.Part0 = part11
  158. wel8.Part1 = trail
  159. wel8.C0 = CFrame.new(-cf3,-0.425,-cf1) * CFrame.Angles(0,math.rad(cf2),0)
  160. end
  161. seat(2.5,90,3.5)
  162. seat(2.5,-90,-3.5)
  163. seat(2.5,-90,-0.5)
  164. seat(2.5,90,0.5)
  165. local atc = Instance.new("Attachment",part)
  166. atc.CFrame = CFrame.new(0,0,6)
  167. local atc2 = Instance.new("Attachment",trail)
  168. atc2.CFrame = CFrame.new(0,0,-7)
  169. trailer.Attachment1 = atc2
  170. trailer.Attachment0 = atc
  171. trailer.LimitsEnabled = true
  172. trailer.UpperAngle = 35
  173. trailer.TwistLimitsEnabled = true
  174. trailer.TwistLowerAngle = -55
  175. trailer.TwistUpperAngle = 55
  176. trailer.Enabled = false
  177. local count = 0
  178. owner.Chatted:Connect(function(msg)
  179. if msg:lower() == "-trailer" then
  180. count += 1
  181. if count == 1 then
  182. if (atc.WorldCFrame.Position - atc2.WorldCFrame.Position).Magnitude < 3 then
  183. trailer.Enabled = true
  184. else
  185. count = 0
  186. end
  187. elseif count == 2 then
  188. trailer.Enabled = false
  189. count = 0
  190. end
  191. end
  192. end)
  193. wait()
  194. local mot1 = suspension(part2,CFrame.new(0,0,0) * CFrame.Angles(0,0,0),true)
  195. local mot2 = suspension(part,CFrame.new(-1.25,1,-3.5),true)
  196. local mot3 = suspension(part3,CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(180),0),true)
  197. local mot4 = suspension(part,CFrame.new(-1.25,1,3.5) * CFrame.Angles(0,math.rad(180),0),true)
  198. suspension(trail,CFrame.new(-2.25,1,0.25) * CFrame.Angles(0,math.rad(180),0),false)
  199. suspension(trail,CFrame.new(-2.25,1,-0.25),false)
  200. suspension(trail,CFrame.new(-2.25,1,3.5) * CFrame.Angles(0,math.rad(180),0),false)
  201. suspension(trail,CFrame.new(-2.25,1,-3.5),false)
  202. mot1.AngularVelocity = 0
  203. mot2.AngularVelocity = 0
  204. mot3.AngularVelocity = 0
  205. mot4.AngularVelocity = 0
  206. wait(0.1)
  207. part.Anchored = false
  208. trail.Anchored = false
  209. local speed = 0
  210. local throt = false
  211. local function carMove(property)
  212. if property == "ThrottleFloat" then
  213. if part.ThrottleFloat ~= 0 then
  214. throt = true
  215. else
  216. throt = false
  217. end
  218. mot1.AngularVelocity = -part.ThrottleFloat * speed
  219. mot2.AngularVelocity = -part.ThrottleFloat * speed
  220. mot3.AngularVelocity = part.ThrottleFloat * speed
  221. mot4.AngularVelocity = part.ThrottleFloat * speed
  222. end
  223. end
  224. lastthrot = 0
  225. local hits = {"rbxassetid://7340406550","rbxassetid://7340406466","rbxassetid://7340406573"}
  226. local hitsound = Instance.new("Sound")
  227. hitsound.PlayOnRemove = true
  228. hitsound.Volume = 0.5
  229. local pe = Instance.new("ParticleEmitter")
  230. pe.Color = ColorSequence.new(Color3.fromRGB(250, 238, 17))
  231. pe.LightEmission = 1
  232. pe.LightInfluence = 0.125
  233. pe.EmissionDirection = "Top"
  234. pe.Orientation = Enum.ParticleOrientation.VelocityParallel
  235. pe.Size = NumberSequence.new(0.35,0)
  236. pe.Texture = "rbxassetid://243132757"
  237. pe.Transparency = NumberSequence.new(0,1)
  238. pe.Lifetime = NumberRange.new(0.5,1)
  239. pe.Rate = 200
  240. pe.Enabled = false
  241. pe.Rotation = NumberRange.new(90)
  242. pe.RotSpeed = NumberRange.new(0)
  243. pe.Speed = NumberRange.new(30)
  244. pe.SpreadAngle = Vector2.new(-35,35)
  245. pe.Drag = NumberRange.new(1)
  246. pe.Acceleration = Vector3.new(0,-65,0)
  247. part.Changed:Connect(carMove)
  248. coroutine.wrap(function()
  249. while task.wait() do
  250. steer.TargetAngle = 37.5 * -part.SteerFloat
  251. steer2.TargetAngle = 37.5 * -part.SteerFloat
  252. sound.Pitch = math.clamp(speed * 0.0625,1,20)
  253. wel4.C0 = wel4.C0:lerp(CFrame.Angles(0,0,math.rad(50 * part.SteerFloat)),0.15)
  254. end
  255. end)()
  256. for i,v in pairs(script:GetDescendants()) do
  257. if v:IsA("Part") then
  258. v.Touched:Connect(function(hit)
  259. if (v.Velocity.Magnitude - hit.Velocity.Magnitude) > 25 and not hit:IsDescendantOf(script) and v.Name ~= "the" then
  260. hitsound.SoundId = hits[math.random(1,3)]
  261. hitsound.Parent = v
  262. hitsound.Parent = nil
  263. pe.Parent = v
  264. pe:Emit(50)
  265. end
  266. end)
  267. end
  268. end
  269. while task.wait() do
  270. if throt and throt ~= -lastthrot then
  271. lastthrot = part.ThrottleFloat
  272. wait(0.0525)
  273. speed = math.clamp(speed + 0.5,0,30)
  274. mot1.AngularVelocity = -part.ThrottleFloat * speed
  275. mot2.AngularVelocity = -part.ThrottleFloat * speed
  276. mot3.AngularVelocity = part.ThrottleFloat * speed
  277. mot4.AngularVelocity = part.ThrottleFloat * speed
  278. elseif throt and throt == -lastthrot then
  279. for i = 1, 60 do
  280. wait(0.0525)
  281. speed = math.clamp(speed - 0.5,0,30)
  282. mot1.AngularVelocity = -lastthrot * speed
  283. mot2.AngularVelocity = -lastthrot * speed
  284. mot3.AngularVelocity = lastthrot * speed
  285. mot4.AngularVelocity = lastthrot * speed
  286. if i == 40 then
  287. lastthrot = part.Throttle
  288. end
  289. end
  290. elseif not throt then
  291. if speed ~= 0 then
  292. wait(0.0325)
  293. end
  294. speed = math.clamp(speed - 0.75,0,30)
  295. mot1.AngularVelocity = -lastthrot * speed
  296. mot2.AngularVelocity = -lastthrot * speed
  297. mot3.AngularVelocity = lastthrot * speed
  298. mot4.AngularVelocity = lastthrot * speed
  299. end
  300. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement