Advertisement
MindOfPlayer

fly

Jul 6th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.96 KB | None | 0 0
  1.    repeat wait() until lplayer and lplayer.Character and lplayer.Character:FindFirstChild('HumanoidRootPart') and lplayer.Character:FindFirstChild('Humanoid')
  2.     repeat wait() until Mouse
  3.    
  4.     local T = lplayer.Character.HumanoidRootPart
  5.     local CONTROL = {F = 0, B = 0, L = 0, R = 0}
  6.     local lCONTROL = {F = 0, B = 0, L = 0, R = 0}
  7.     local SPEED = speedget
  8.    
  9.     local function fly()
  10.         flying = true
  11.         local BG = Instance.new('BodyGyro', T)
  12.         local BV = Instance.new('BodyVelocity', T)
  13.         BG.P = 9e4
  14.         BG.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  15.         BG.cframe = T.CFrame
  16.         BV.velocity = Vector3.new(0, 0.1, 0)
  17.         BV.maxForce = Vector3.new(9e9, 9e9, 9e9)
  18.         spawn(function()
  19.         repeat wait()
  20.         lplayer.Character.Humanoid.PlatformStand = true
  21.         if CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0 then
  22.         SPEED = 50
  23.         elseif not (CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0) and SPEED ~= 0 then
  24.         SPEED = 0
  25.         end
  26.         if (CONTROL.L + CONTROL.R) ~= 0 or (CONTROL.F + CONTROL.B) ~= 0 then
  27.         BV.velocity = ((workspace.CurrentCamera.CoordinateFrame.lookVector * (CONTROL.F + CONTROL.B)) + ((workspace.CurrentCamera.CoordinateFrame * CFrame.new(CONTROL.L + CONTROL.R, (CONTROL.F + CONTROL.B) * 0.2, 0).p) - workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
  28.         lCONTROL = {F = CONTROL.F, B = CONTROL.B, L = CONTROL.L, R = CONTROL.R}
  29.         elseif (CONTROL.L + CONTROL.R) == 0 and (CONTROL.F + CONTROL.B) == 0 and SPEED ~= 0 then
  30.         BV.velocity = ((workspace.CurrentCamera.CoordinateFrame.lookVector * (lCONTROL.F + lCONTROL.B)) + ((workspace.CurrentCamera.CoordinateFrame * CFrame.new(lCONTROL.L + lCONTROL.R, (lCONTROL.F + lCONTROL.B) * 0.2, 0).p) - workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
  31.         else
  32.         BV.velocity = Vector3.new(0, 0.1, 0)
  33.         end
  34.         BG.cframe = workspace.CurrentCamera.CoordinateFrame
  35.                 until not flying
  36.                 CONTROL = {F = 0, B = 0, L = 0, R = 0}
  37.                 lCONTROL = {F = 0, B = 0, L = 0, R = 0}
  38.                 SPEED = 0
  39.                 BG:destroy()
  40.                 BV:destroy()
  41.                 lplayer.Character.Humanoid.PlatformStand = false
  42.             end)
  43.         end
  44.     Mouse.KeyDown:connect(function(KEY)
  45.         if KEY:lower() == 'w' then
  46.             CONTROL.F = speedfly
  47.         elseif KEY:lower() == 's' then
  48.             CONTROL.B = -speedfly
  49.         elseif KEY:lower() == 'a' then
  50.             CONTROL.L = -speedfly
  51.         elseif KEY:lower() == 'd' then
  52.             CONTROL.R = speedfly
  53.         end
  54.     end)
  55.     Mouse.KeyUp:connect(function(KEY)
  56.         if KEY:lower() == 'w' then
  57.             CONTROL.F = 0
  58.         elseif KEY:lower() == 's' then
  59.             CONTROL.B = 0
  60.         elseif KEY:lower() == 'a' then
  61.             CONTROL.L = 0
  62.         elseif KEY:lower() == 'd' then
  63.             CONTROL.R = 0
  64.         end
  65.     end)
  66.     fly()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement