Advertisement
EasyDevX

fly

Apr 20th, 2024 (edited)
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | None | 0 0
  1. -- Press X to fly
  2.  
  3. local plr = game.Players.LocalPlayer
  4.     local mouse = plr:GetMouse()
  5.  
  6.     localplayer = plr
  7.  
  8.     if workspace:FindFirstChild("Core") then
  9.         workspace.Core:Destroy()
  10.     end
  11.  
  12.     local Core = Instance.new("Part")
  13.     Core.Name = "Core"
  14.     Core.Size = Vector3.new(0.05, 0.05, 0.05)
  15.  
  16.     spawn(function()
  17.         Core.Parent = workspace
  18.         local Weld = Instance.new("Weld", Core)
  19.         Weld.Part0 = Core
  20.         Weld.Part1 = localplayer.Character.LowerTorso
  21.         Weld.C0 = CFrame.new(0, 0, 0)
  22.     end)
  23.  
  24.     workspace:WaitForChild("Core")
  25.  
  26.     local torso = workspace.Core
  27.     flying = true
  28.     local speed=20
  29.     local keys={a=false,d=false,w=false,s=false}
  30.     local e1
  31.     local e2
  32.     local function start()
  33.         local pos = Instance.new("BodyPosition",torso)
  34.         local gyro = Instance.new("BodyGyro",torso)
  35.         pos.Name="EPIXPOS"
  36.         pos.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  37.         pos.position = torso.Position
  38.         gyro.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  39.         gyro.cframe = torso.CFrame
  40.         repeat
  41.             wait()
  42.             localplayer.Character.Humanoid.PlatformStand=true
  43.             local new=gyro.cframe - gyro.cframe.p + pos.position
  44.             if not keys.w and not keys.s and not keys.a and not keys.d then
  45.                 speed=5
  46.             end
  47.             if keys.w then
  48.                 new = new + workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  49.                 speed=speed+0
  50.             end
  51.             if keys.s then
  52.                 new = new - workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  53.                 speed=speed+0
  54.             end
  55.             if keys.d then
  56.                 new = new * CFrame.new(speed,0,0)
  57.                 speed=speed+0
  58.             end
  59.             if keys.a then
  60.                 new = new * CFrame.new(-speed,0,0)
  61.                 speed=speed+0
  62.             end
  63.             if speed>10 then
  64.                 speed=5
  65.             end
  66.             pos.position=new.p
  67.             if keys.w then
  68.                 gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(-math.rad(speed*0),0,0)
  69.             elseif keys.s then
  70.                 gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(math.rad(speed*0),0,0)
  71.             else
  72.                 gyro.cframe = workspace.CurrentCamera.CoordinateFrame
  73.             end
  74.         until flying == false
  75.         if gyro then gyro:Destroy() end
  76.         if pos then pos:Destroy() end
  77.         flying=false
  78.         localplayer.Character.Humanoid.PlatformStand=false
  79.         speed=20
  80.     end
  81.     e1=mouse.KeyDown:connect(function(key)
  82.         if not torso or not torso.Parent then flying=false e1:disconnect() e2:disconnect() return end
  83.         if key=="w" then
  84.             keys.w=true
  85.         elseif key=="s" then
  86.             keys.s=true
  87.         elseif key=="a" then
  88.             keys.a=true
  89.         elseif key=="d" then
  90.             keys.d=true
  91.         elseif key=="x" then
  92.             if flying==true then
  93.                 flying=false
  94.             else
  95.                 flying=true
  96.                 start()
  97.             end
  98.         end
  99.     end)
  100.     e2=mouse.KeyUp:connect(function(key)
  101.         if key=="w" then
  102.             keys.w=false
  103.         elseif key=="s" then
  104.             keys.s=false
  105.         elseif key=="a" then
  106.             keys.a=false
  107.         elseif key=="d" then
  108.             keys.d=false
  109.         end
  110.     end)
  111.     start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement