Advertisement
eeweww

Fly Roblox Script

Apr 2nd, 2023 (edited)
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | Gaming | 0 0
  1. --[[
  2.     Made by: shany26M10 on roblox
  3. ]]--
  4.  
  5. repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:findFirstChild("Torso") and game.Players.LocalPlayer.Character:findFirstChild("Humanoid")
  6. local mouse = game.Players.LocalPlayer:GetMouse()
  7. repeat wait() until mouse
  8.   local plr = game.Players.LocalPlayer
  9.   local torso = plr.Character.Torso
  10.   local flying = true
  11.   local deb = true
  12.   local ctrl = {f = 0, b = 0, l = 0, r = 0}
  13.   local lastctrl = {f = 0, b = 0, l = 0, r = 0}
  14.   local maxspeed = 50
  15.   local speed = 0
  16.  
  17.   function Fly()
  18.     local bg = Instance.new("BodyGyro", torso)
  19.     bg.P = 9e4
  20.     bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  21.     bg.cframe = torso.CFrame
  22.     local bv = Instance.new("BodyVelocity", torso)
  23.     bv.velocity = Vector3.new(0,0.1,0)
  24.     bv.maxForce = Vector3.new(9e9, 9e9, 9e9)
  25.     repeat wait()
  26.       if ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0 then
  27.         speed = speed+.5+(speed/maxspeed)
  28.         if speed > maxspeed then
  29.           speed = maxspeed
  30.         end
  31.       elseif not (ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0) and speed ~= 0 then
  32.         speed = speed-1
  33.         if speed < 0 then
  34.           speed = 0
  35.         end
  36.       end
  37.       if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then
  38.         bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (ctrl.f+ctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(ctrl.l+ctrl.r,(ctrl.f+ctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed
  39.         lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r}
  40.       elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed ~= 0 then
  41.         bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (lastctrl.f+lastctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(lastctrl.l+lastctrl.r,(lastctrl.f+lastctrl.b)*.2,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*speed
  42.       else
  43.         bv.velocity = Vector3.new(0,0.1,0)
  44.       end
  45.       bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad((ctrl.f+ctrl.b)*50*speed/maxspeed),0,0)
  46.     until not flying
  47.     ctrl = {f = 0, b = 0, l = 0, r = 0}
  48.     lastctrl = {f = 0, b = 0, l = 0, r = 0}
  49.     speed = 0
  50.     bg:Destroy()
  51.     bv:Destroy()
  52.   end
  53.   mouse.KeyDown:connect(function(key)
  54.   if key:lower() == "e" then
  55.     if flying then flying = false
  56.   else
  57.     flying = true
  58.     Fly()
  59.   end
  60. elseif key:lower() == "w" then
  61.   ctrl.f = 1
  62. elseif key:lower() == "s" then
  63.   ctrl.b = -1
  64. elseif key:lower() == "a" then
  65.   ctrl.l = -1
  66. elseif key:lower() == "d" then
  67.   ctrl.r = 1
  68. end
  69. end)
  70. mouse.KeyUp:connect(function(key)
  71. if key:lower() == "w" then
  72.   ctrl.f = 0
  73. elseif key:lower() == "s" then
  74.   ctrl.b = 0
  75. elseif key:lower() == "a" then
  76.   ctrl.l = 0
  77. elseif key:lower() == "d" then
  78.   ctrl.r = 0
  79. end
  80. end)
  81. Fly()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement