Advertisement
Guest User

Hoverboard Script

a guest
Feb 28th, 2020
1,805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.46 KB | None | 0 0
  1. -- Script
  2.  
  3. local vUpdate=require(script:WaitForChild("VehicleUpdater"))
  4.  
  5. local player=nil
  6.  
  7. function stopAnims(target)
  8. local Humanoid = target.Humanoid
  9. local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
  10. for _,v in pairs(ActiveTracks) do
  11. v:Stop()
  12. end
  13. end
  14.  
  15. script.Parent.ChildAdded:connect(function(v)
  16. if v:IsA("Weld") and v.Name=="SeatWeld" then --Hey, players use this to sit!
  17. player=game.Players:GetPlayerFromCharacter(v.Part1.Parent)
  18. if player then --WE GOT ONE!!!
  19. script.VControls:Clone().Parent=player.PlayerGui
  20. end
  21. end
  22. end)
  23. script.Parent.ChildRemoved:connect(function(v)
  24. if v:IsA("Weld") and v.Name=="SeatWeld" and player then
  25. local scr=player.PlayerGui:FindFirstChild("VControls")
  26. if scr then scr:Destroy() end
  27. end
  28. end)
  29.  
  30. script.Parent.ChildRemoved:connect(function(v)
  31. if v:IsA("Weld") and v.Name=="SeatWeld" then
  32. local plr = game.Players:FindFirstChild(v.Part1.Parent.Name)
  33. local char = plr.Character
  34.  
  35. stopAnims(char)
  36. end
  37. end)
  38.  
  39. -- Local Script
  40.  
  41. local pl=game.Players.LocalPlayer
  42. local cam=workspace.CurrentCamera
  43. local seat=cam.CameraSubject
  44. local vehicle=seat.Parent
  45. local boost = false
  46. local db = false
  47. local UIS = game:GetService("UserInputService")
  48.  
  49. UIS.InputBegan:Connect(function(input)
  50. if input.KeyCode == Enum.KeyCode.LeftShift and boost == false and db == false then
  51. db = true
  52. boost = true
  53. wait(.2)
  54. boost = false
  55. wait(4)
  56. db = false
  57. end
  58. end)
  59.  
  60. local vUpdate = require(seat.Engine:FindFirstChild("VehicleUpdater"))
  61.  
  62. while wait() do
  63. vUpdate(pl,vehicle,boost)
  64. end
  65.  
  66. -- Module Script
  67.  
  68. local handling = ( 2 ) *.05;
  69. local maxTurn = ( 4 );
  70. local acceleration = ( 1.5 ) *.03;
  71. local topSpeed = ( 5 ) + 60;
  72.  
  73. local visualTorque = ( 5 ) *.1
  74.  
  75.  
  76. local boospeed=0
  77. local debounce=false
  78. local zoomin=false
  79. local Animations = script.Parent.Parent.Parent.Animations
  80. local LastAnim
  81.  
  82. local function boost(boospe,vel,seat,cam, player,vehicle,canboost)
  83. local boostSound=seat.Boost
  84. boostSound:Play()
  85.  
  86. script.Parent.Parent.Parent.Base.Trail1.Enabled = true
  87. script.Parent.Parent.Parent.Base.Trail2.Enabled = true
  88.  
  89. debounce=true
  90.  
  91. boospeed=boospe
  92. vel.velocity=vel.velocity+seat.CFrame.lookVector*boospe
  93. for i=1,15 do
  94. cam.FieldOfView =(70+i)
  95. game:GetService("RunService").RenderStepped:wait()
  96. end
  97. cam.FieldOfView = 85
  98. --cam.FieldOfView=10
  99. wait(.5)
  100. for i=1,15 do
  101. cam.FieldOfView =(85-i)
  102. game:GetService("RunService").RenderStepped:wait()
  103. end
  104. cam.FieldOfView = 70
  105. script.Parent.Parent.Parent.Base.Trail1.Enabled = false
  106. script.Parent.Parent.Parent.Base.Trail2.Enabled = false
  107. debounce=false
  108. UpdateHoverboard(player,vehicle,canboost)
  109. end
  110.  
  111. function stopAnims(target)
  112. local Humanoid = target.Humanoid
  113. local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
  114. for _,v in pairs(ActiveTracks) do
  115. v:Stop()
  116. end
  117. end
  118.  
  119. function UpdateAnims(target,currentAnim)
  120. if currentAnim == "Moving" and currentAnim ~= LastAnim and script.Parent.Parent:FindFirstChild("SeatWeld") then
  121. LastAnim = currentAnim
  122. stopAnims(target)
  123. if script.Parent.Parent:FindFirstChild("SeatWeld") then
  124. target.Humanoid:LoadAnimation(Animations.Moving):Play()
  125. end
  126. elseif currentAnim == "Idle" and currentAnim ~= LastAnim and script.Parent.Parent:FindFirstChild("SeatWeld") then
  127. LastAnim = currentAnim
  128. stopAnims(target)
  129. if script.Parent.Parent:FindFirstChild("SeatWeld") then
  130. target.Humanoid:LoadAnimation(Animations.Idle):Play()
  131. end
  132. elseif script.Parent.Parent:FindFirstChild("SeatWeld") == nil then
  133. stopAnims(target)
  134. game:GetService("Debris"):AddItem(script.Parent.Parent.Parent, .5)
  135. end
  136. end
  137.  
  138. function UpdateHoverboard(player,vehicle,canboost)
  139. if script.Parent.Parent:FindFirstChild("SeatWeld") then
  140. else
  141. stopAnims(player.Character)
  142. script.Parent.Parent.Idle:Stop()
  143. script.Parent.Parent.Boost:Stop()
  144.  
  145. local seat=vehicle:FindFirstChild("VehicleSeat")
  146.  
  147. local angv=seat:FindFirstChild("angv")
  148. local vel=seat:FindFirstChild("vel")
  149. local gyro=seat:FindFirstChild("gy")
  150.  
  151. vel.velocity=vel.velocity:Lerp(Vector3.new(0, 0, 0), 1)
  152. end
  153. end
  154.  
  155. return function(player,vehicle,canboost)
  156. if script.Parent.Parent:FindFirstChild("SeatWeld") == nil then
  157. stopAnims(player.Character)
  158. script.Parent.Parent.Idle:Stop()
  159. script.Parent.Parent.Boost:Stop()
  160.  
  161. local seat=vehicle:FindFirstChild("VehicleSeat")
  162.  
  163. local angv=seat:FindFirstChild("angv")
  164. local vel=seat:FindFirstChild("vel")
  165. local gyro=seat:FindFirstChild("gy")
  166.  
  167. vel.velocity=vel.velocity:Lerp(Vector3.new(0, 0, 0), 1)
  168. else
  169. local cam=workspace.CurrentCamera
  170.  
  171. local seat=vehicle:FindFirstChild("VehicleSeat")
  172.  
  173. local angv=seat:FindFirstChild("angv")
  174. local vel=seat:FindFirstChild("vel")
  175. local gyro=seat:FindFirstChild("gy")
  176.  
  177. local variables=vehicle:FindFirstChild("Variables")
  178. local speed=variables.Speed
  179.  
  180. --Control
  181. if seat.Steer~=0 then
  182. variables.turnSpeed.Value=maxTurn*seat.Steer
  183. else
  184. variables.turnSpeed.Value=0
  185. end
  186. if seat.Throttle==1 then
  187. speed.Value=topSpeed+boospeed
  188. UpdateAnims(player.Character, "Moving")
  189. UpdateHoverboard(player,vehicle,canboost)
  190. elseif seat.Throttle==-1 then
  191. speed.Value=-topSpeed/4-boospeed
  192. UpdateAnims(player.Character, "Idle")
  193. UpdateHoverboard(player,vehicle,canboost)
  194. else
  195. speed.Value=0
  196. UpdateAnims(player.Character, "Idle")
  197. UpdateHoverboard(player,vehicle,canboost)
  198. end
  199.  
  200. --Update
  201. local idle=seat.Idle
  202. if not idle.IsPlaying then idle:Play() end
  203. idle.Pitch=.3+(vel.velocity.Magnitude/topSpeed)
  204.  
  205. local lv=seat.CFrame.lookVector
  206. local roll=(-angv.angularvelocity.y/maxTurn)*((vel.velocity.Magnitude/topSpeed)*.2+.2)
  207.  
  208. vel.velocity=vel.velocity:Lerp(lv*variables.Speed.Value,acceleration)
  209. if seat.Orientation.X > 3 then
  210. angv.angularvelocity=angv.angularvelocity:Lerp(Vector3.new(-3,-variables.turnSpeed.Value/1.5,0),handling)
  211. elseif seat.Orientation.X < -3 then
  212. angv.angularvelocity=angv.angularvelocity:Lerp(Vector3.new(3,-variables.turnSpeed.Value/1.5,0),handling)
  213. else
  214. angv.angularvelocity=angv.angularvelocity:Lerp(Vector3.new(0,-variables.turnSpeed.Value/1.5,0),handling)
  215. end
  216. gyro.cframe=CFrame.fromAxisAngle(lv,roll)
  217.  
  218. if boospeed<=0 then boospeed=0 else boospeed=boospeed-1 end
  219. if zoomin==false then cam.FieldOfView=(70-cam.FieldOfView)*.05+cam.FieldOfView end
  220.  
  221. cam.CameraType="Track"
  222.  
  223. if canboost == true and debounce==false then boost(50,vel,seat,cam, player,vehicle,canboost) end
  224. end
  225. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement