Advertisement
Guest User

Fly script

a guest
Aug 11th, 2022
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.67 KB | None | 0 0
  1.  
  2. _G.FLYING = false
  3. local LP = game:service('Players').LocalPlayer
  4. local T = LP.Character.UpperTorso
  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 = 5
  8. local MOUSE = LP:GetMouse()
  9.  
  10.  
  11. local function FLY()
  12.     _G.FLYING = true --make it false = no fly
  13.     local BG = Instance.new('BodyGyro', T)
  14.     local BV = Instance.new('BodyVelocity', T)
  15.     BG.P = 9e4
  16.     BG.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  17.     BG.cframe = T.CFrame
  18.     BV.velocity = Vector3.new(0, 0.1, 0)
  19.     BV.maxForce = Vector3.new(9e9, 9e9, 9e9)
  20.  
  21.  
  22.     spawn(function()
  23.       repeat wait()
  24.         LP.Character.Humanoid.PlatformStand = true
  25.         if CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0 then
  26.           SPEED = 50
  27.         elseif not (CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0) and SPEED ~= 0 then
  28.           SPEED = 0
  29.         end
  30.         if (CONTROL.L + CONTROL.R) ~= 0 or (CONTROL.F + CONTROL.B) ~= 0 then
  31.           BV.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (CONTROL.F + CONTROL.B)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(CONTROL.L + CONTROL.R, (CONTROL.F + CONTROL.B) * 0.2, 0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
  32.           lCONTROL = {F = CONTROL.F, B = CONTROL.B, L = CONTROL.L, R = CONTROL.R}
  33.         elseif (CONTROL.L + CONTROL.R) == 0 and (CONTROL.F + CONTROL.B) == 0 and SPEED ~= 0 then
  34.           BV.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (lCONTROL.F + lCONTROL.B)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(lCONTROL.L + lCONTROL.R, (lCONTROL.F + lCONTROL.B) * 0.2, 0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
  35.         else
  36.           BV.velocity = Vector3.new(0, 0.1, 0)
  37.         end
  38.         BG.cframe = game.Workspace.CurrentCamera.CoordinateFrame
  39.       until not _G.FLYING
  40.       CONTROL = {F = 0, B = 0, L = 0, R = 0}
  41.       lCONTROL = {F = 0, B = 0, L = 0, R = 0}
  42.       SPEED = 0
  43.       BG:destroy()
  44.       BV:destroy()
  45.       LP.Character.Humanoid.PlatformStand = false
  46.     end)
  47.   end
  48.  
  49.   MOUSE.KeyDown:connect(function(KEY)
  50.     if KEY:lower() == 'w' then
  51.       CONTROL.F = 1
  52.     elseif KEY:lower() == 's' then
  53.       CONTROL.B = -1
  54.     elseif KEY:lower() == 'a' then
  55.       CONTROL.L = -1
  56.     elseif KEY:lower() == 'd' then
  57.       CONTROL.R = 1
  58.     end
  59.   end)
  60.  
  61.   MOUSE.KeyUp:connect(function(KEY)
  62.     if KEY:lower() == 'w' then
  63.       CONTROL.F = 0
  64.     elseif KEY:lower() == 's' then
  65.       CONTROL.B = 0
  66.     elseif KEY:lower() == 'a' then
  67.       CONTROL.L = 0
  68.     elseif KEY:lower() == 'd' then
  69.       CONTROL.R = 0
  70.     end
  71.   end)
  72.  
  73.  
  74.  
  75.  
  76.   FLY()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement