SHARE
TWEET

Untitled

a guest Oct 14th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local player = game.Players.LocalPlayer
  2. local character = player.Character or player.CharacterAdded:Wait()
  3. local root = character:WaitForChild("HumanoidRootPart")
  4. local humanoid = character:WaitForChild("Humanoid")
  5. local bp;
  6. local bg;
  7. local flying = false
  8.  
  9. local function unfly()
  10.     flying = false
  11.     wait()
  12.     print('called')
  13.     humanoid.PlatformStand = false
  14.     if bp then
  15.         bp:Destroy()
  16.     end
  17.     if bg then
  18.         bg:Destroy()
  19.     end
  20. end
  21.  
  22. local function fly()
  23.     flying = true
  24.     bp = Instance.new("BodyPosition",root)
  25.     bg = Instance.new("BodyGyro",root)
  26.    
  27.     bg.P = 12000
  28.     bg.maxTorque = Vector3.new(math.huge,9e9,math.huge)
  29.     bg.cframe = root.CFrame
  30.    
  31.     local function straight()
  32.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.lookVector * 25
  33.     end
  34.    
  35.     local function back()
  36.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.lookVector * -25
  37.     end
  38.    
  39.     local function left()
  40.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * -25
  41.     end
  42.    
  43.     local function right()
  44.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * 25
  45.     end
  46.    
  47.     local function cornerUp()
  48.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * 25 + workspace.CurrentCamera.CFrame.lookVector * 25
  49.     end
  50.    
  51.     local function cornerDown()
  52.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * -25 + workspace.CurrentCamera.CFrame.lookVector * 25
  53.     end
  54.    
  55.     local function downRight()
  56.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * 25 + workspace.CurrentCamera.CFrame.lookVector * -25
  57.     end
  58.    
  59.     local function downLeft()
  60.         bp.Position = root.Position + workspace.CurrentCamera.CFrame.rightVector * -25 + workspace.CurrentCamera.CFrame.lookVector * -25
  61.     end
  62.    
  63.     local holdingw = false
  64.     local holdinga = false
  65.     local holdings = false
  66.     local holdingd = false
  67.    
  68.     local connection = game:GetService("UserInputService").InputBegan:Connect(function(i,t)
  69.         if not t and flying then
  70.             if i.KeyCode == Enum.KeyCode.W then
  71.                 holdingw = true
  72.             end
  73.             if i.KeyCode == Enum.KeyCode.A then
  74.                 holdinga = true
  75.             end
  76.             if i.KeyCode == Enum.KeyCode.S then
  77.                 holdings = true
  78.             end
  79.             if i.KeyCode == Enum.KeyCode.D then
  80.                 holdingd = true
  81.             end
  82.         end
  83.     end)
  84.    
  85.     local connection2 = game:GetService("UserInputService").InputEnded:Connect(function(i)
  86.         if flying then
  87.             if i.KeyCode == Enum.KeyCode.W then
  88.                 holdingw = false
  89.             end
  90.             if i.KeyCode == Enum.KeyCode.A then
  91.                 holdinga = false
  92.             end
  93.             if i.KeyCode == Enum.KeyCode.S then
  94.                 holdings = false
  95.             end
  96.             if i.KeyCode == Enum.KeyCode.D then
  97.                 holdingd = false
  98.             end
  99.         end
  100.     end)
  101.    
  102.     spawn(function()
  103.         while game:GetService("RunService").RenderStepped:Wait() and flying do
  104.             bg.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(0,0,0)
  105.         end
  106.     end)
  107.    
  108.     spawn(function()
  109.         while true do
  110.             if not flying then return end
  111.             wait()
  112.             print('running')
  113.             humanoid.PlatformStand = true
  114.             if holdingw and not holdingd then
  115.                 straight()
  116.             else
  117.                 if holdingw and holdingd then
  118.                     cornerUp()
  119.                 end
  120.             end
  121.             if holdinga and not holdingw and not holdings then
  122.                 left()
  123.             else
  124.                 if holdinga and holdingw and not holdings then
  125.                     cornerDown()
  126.                 else
  127.                     if holdinga and holdings then
  128.                         downLeft()
  129.                     end
  130.                 end
  131.             end
  132.             if holdingd and not holdingw and not holdings then
  133.                 right()
  134.             else
  135.                 if holdingd and holdings then
  136.                     downRight()
  137.                 end
  138.             end
  139.             if holdings and not holdingw and not holdinga and not holdingd and not holdinga then
  140.                 back()
  141.             else
  142.                 if holdings and holdingd then
  143.                     downRight()
  144.                 end
  145.             end
  146.         end
  147.     end)
  148. end
  149.  
  150. fly()
  151. wait(3)
  152. unfly()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top