Advertisement
lossdev

fly

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