Advertisement
Velinquish

Controllable Forward Thrust Solution

Apr 10th, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. local CAS = game:GetService("ContextActionService")
  2. local RunService = game:GetService("RunService")
  3.  
  4. local player = game.Players.LocalPlayer
  5. local character = player.Character or player.CharacterAdded:Wait()
  6.  
  7. local forwardLoop
  8. local thruster = Instance.new("BodyVelocity")
  9. thruster.MaxForce = Vector3.new()
  10. thruster.Parent = character.HumanoidRootPart
  11.  
  12. local jetpack_on = false
  13.  
  14. local function jetpack()
  15.     jetpack_on = not jetpack_on
  16.     print("Jetpack:", jetpack_on)
  17.     if jetpack_on then
  18.         thruster.MaxForce = Vector3.new(5000, 5000, 5000)
  19.         forwardLoop = RunService.Heartbeat:Connect(function()
  20.             thruster.Velocity = Vector3.new(0, 20, 0) + character.HumanoidRootPart.CFrame.LookVector * 30
  21.         end)
  22.         return
  23.     end
  24.     thruster.MaxForce = Vector3.new()
  25.     forwardLoop:Disconnect()
  26. end
  27.  
  28. CAS:BindAction("Jetpack", jetpack, false, Enum.KeyCode.LeftShift)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement