Advertisement
SpacecowboyHX

car script

Jun 4th, 2021 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.24 KB | None | 0 0
  1. local p = game.Players.LocalPlayer
  2. local serv = game:GetService("UserInputService")
  3. --workspace.Gravity = 98.1
  4. local m = p:GetMouse()
  5. local axcelSpeed = 1--how fast the car speeds up
  6. local Tiregrip = 0.5--how fast the car slows down
  7. local prog = 0
  8. local Tprog = 0
  9. local letoff = true -- wether or not the car have letoff
  10. local speed = 10--how fast the car goes
  11. local turnspeed = 1 -- how fast u turn
  12. local vel = Vector3.new(0,0,0)
  13. local intensity = 20 -- how much you want the fov to change
  14. local maxLean = 11.25 -- the max degrees your car will lean back when moving
  15. local carHeight = 0 -- how high up ur car is going to be
  16. speed = speed/10
  17. turnspeed = turnspeed/10
  18. local last = Vector3.new(0,0,0)
  19. local FPS = 0
  20. spawn(function()
  21. local startT = tick()
  22. local count = 0
  23. game:GetService("RunService").RenderStepped:Connect(function()
  24. if tick()-startT>=1 then
  25. startT = tick()
  26. FPS = count
  27. count = 0
  28. --print(FPS)
  29. else
  30. count = count+1
  31. end
  32. end)
  33. end)
  34. local since = math.huge
  35. local gain = false
  36. function chat(msg)
  37. local all = game.Players:GetChildren()
  38. game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer(msg, 'All')
  39. --p:Chat(msg)
  40. end
  41. local anim = Instance.new("Animation")
  42. anim.AnimationId = "rbxassetid://129342287"
  43. repeat wait() until p.Character~=nil
  44. local hums = p.Character:WaitForChild("Humanoid")
  45. local original
  46. if hums then
  47. local animation1 = hums:LoadAnimation(anim)
  48. animation1:Play()
  49. animation1:AdjustSpeed(1)
  50. local r = p.Character:FindFirstChild("HumanoidRootPart")
  51. repeat wait() r = p.Character:FindFirstChild("HumanoidRootPart") until r
  52. local joint = r:WaitForChild("RootJoint")
  53. if joint then
  54. print("changing joint")
  55. joint.C0 = CFrame.new(0,carHeight,0)*CFrame.Angles(math.pi/2,math.pi,0)
  56. original = joint.C0
  57. end
  58. end
  59. local function reX(cframe)
  60. local x, y, z = cframe:ToOrientation()
  61. return CFrame.new(cframe.Position) * CFrame.Angles(0,y,z)
  62. end
  63. function Lerp(a, b, c)
  64. return a + ((b - a) * c)
  65. end
  66. local randoN = 0
  67. local back
  68. spawn(function()--MADE BY DOJJ0 ! ! !
  69. local startTick = tick()
  70. back = game:GetService("RunService").RenderStepped:Connect(function()
  71. if tick()-startTick>=((0.0166666667*FPS)-1)/150 then
  72. startTick = tick()
  73. local c = p.Character
  74. if c then
  75. local root = c.PrimaryPart
  76. if root then
  77. local hum = c:FindFirstChild("Humanoid")
  78. if hum and hum.Health>0 then
  79. local mag = (last-root.Position).Magnitude*10
  80. last = root.Position
  81. local look = root.CFrame.LookVector
  82. prog = math.clamp(prog-Tiregrip,0,100)
  83. if letoff == true then
  84. if prog>=95 and gain == false then
  85. randoN = math.random(1,10)
  86. print(randoN)
  87. gain = true
  88. --print("gaining")
  89. since = tick()
  90. --prog = math.random(50,70)
  91. else
  92. if prog>=95 then
  93. --print("gaining speed")
  94. if tick()-since>= randoN then
  95. local to = math.random(50,70)
  96. spawn(function()
  97. for i = .1,1,.1 do
  98. wait()
  99. prog = Lerp(prog,to,i)
  100. end
  101. end)
  102. since = math.huge
  103. gain = false
  104. print("letting off")
  105. else
  106. --print(tick()-since)
  107. end
  108. else
  109. gain = false
  110. since = math.huge
  111. --print("lost gain")
  112. end
  113. end
  114. end
  115. local calc2 = math.clamp(math.floor(mag*1000),0.1,1)
  116. --print(calc2)
  117. local cam = workspace.CurrentCamera
  118. if cam then
  119. cam.FieldOfView = 70+((intensity/100)*prog)
  120. end
  121. if not serv:IsKeyDown(Enum.KeyCode.A) and not serv:IsKeyDown(Enum.KeyCode.D) then
  122. if Tprog<0 then
  123. --print("under")
  124. if Tprog+Tiregrip*8>0 then
  125. Tprog = 0
  126. else
  127. Tprog = Tprog+Tiregrip*8
  128. end
  129. else
  130. --print("over")
  131. if Tprog-Tiregrip*8<0 then
  132. Tprog = 0
  133. else
  134. Tprog = Tprog-Tiregrip*8
  135. end
  136. end
  137. end
  138. --print(Tproh)
  139. local torso = c:FindFirstChild("HumanoidRootPart")
  140. if torso then
  141. local joint = torso:FindFirstChild("RootJoint")
  142. if joint then
  143. --print(((maxLean/100)*prog))
  144. joint.C0 = original*CFrame.Angles(math.rad(-((maxLean/100)*prog)),math.rad(((maxLean/100)*Tprog)),0)
  145. end
  146. end
  147. c:SetPrimaryPartCFrame(reX(c:GetPrimaryPartCFrame())*CFrame.new(0,0,-(((speed/100)*prog)*calc2))*CFrame.Angles(math.rad(((maxLean/100)*prog)),0,0))
  148. c:SetPrimaryPartCFrame(root.CFrame*CFrame.fromOrientation(0,(turnspeed/100)*(Tprog*((speed/100)*(100-(prog/1.5)))),0))
  149. else
  150. back:Disconnect()
  151. end
  152. end
  153. end
  154. end
  155. end)
  156. end)
  157. local run
  158. local startTick2 = tick()
  159. run = game:GetService("RunService").RenderStepped:Connect(function()
  160. if tick()-startTick2>=((0.0166666667*FPS)-1)/150 then
  161. startTick2 = tick()
  162. local c = p.Character
  163. if c then
  164. local hum = c:FindFirstChildOfClass("Humanoid")
  165. if hum and hum.Health>0 then
  166. --hum.WalkSpeed = 0
  167. if serv:IsKeyDown(Enum.KeyCode.W) then
  168. local root = c.PrimaryPart
  169. if root then
  170. local look = root.CFrame.LookVector
  171. prog = math.clamp(prog+(axcelSpeed*2),0,100)
  172. --vel = (look*((speed/100)*prog)).Unit
  173. --print(vel)
  174. end
  175. end
  176. if serv:IsKeyDown(Enum.KeyCode.A) then
  177. --print("left")
  178. local root = c.PrimaryPart
  179. if root then
  180. Tprog = math.clamp((Tprog+axcelSpeed*(8)),-100,100)
  181. --root.CFrame = root.CFrame*CFrame.fromOrientation(0,(turnspeed/100)*Tprog,0)
  182. end
  183. end
  184. if serv:IsKeyDown(Enum.KeyCode.D) then
  185. --print("right")
  186. local root = c.PrimaryPart
  187. if root then
  188. Tprog = math.clamp((Tprog-axcelSpeed*8),-100,100)
  189. end
  190. end
  191. if serv:IsKeyDown(Enum.KeyCode.S) then
  192. local root = c.PrimaryPart
  193. if root then
  194. local look = root.CFrame.LookVector
  195. prog = math.clamp(prog-Tiregrip*2,0,100)
  196. --vel = (look*((speed/100)*prog)).Unit
  197. end
  198. end
  199. else
  200. run:Disconnect()
  201. end
  202. end
  203. end
  204. end)
  205. m.KeyDown:Connect(function(key)
  206. if string.lower(key)=="e" then
  207. chat("beep beep!")
  208. else
  209. if string.lower(key)=="q" then
  210. chat("vroom vroom")
  211. end
  212. end
  213. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement