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")Â
local mouse = game.Players.LocalPlayer:GetMouse()Â
repeat wait() until mouse
local plr = game.Players.LocalPlayerÂ
local torso = plr.Character.TorsoÂ
local flying = true
local deb = trueÂ
local ctrl = {f = 0, b = 0, l = 0, r = 0}Â
local lastctrl = {f = 0, b = 0, l = 0, r = 0}Â
local maxspeed = 50Â
local speed = 0Â
function Fly()Â
local bg = Instance.new("BodyGyro", torso)Â
bg.P = 9e4Â
bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)Â
bg.cframe = torso.CFrameÂ
local bv = Instance.new("BodyVelocity", torso)Â
bv.velocity = Vector3.new(0,0.1,0)Â
bv.maxForce = Vector3.new(9e9, 9e9, 9e9)Â
repeat wait()Â
plr.Character.Humanoid.PlatformStand = trueÂ
if ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0 thenÂ
speed = speed+.5+(speed/maxspeed)Â
if speed > maxspeed thenÂ
speed = maxspeedÂ
endÂ
elseif not (ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0) and speed ~= 0 thenÂ
speed = speed-1Â
if speed < 0 thenÂ
speed = 0Â
endÂ
endÂ
if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 thenÂ
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Â
lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r}Â
elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed ~= 0 thenÂ
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Â
elseÂ
bv.velocity = Vector3.new(0,0.1,0)Â
endÂ
bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad((ctrl.f+ctrl.b)*50*speed/maxspeed),0,0)Â
until not flyingÂ
ctrl = {f = 0, b = 0, l = 0, r = 0}Â
lastctrl = {f = 0, b = 0, l = 0, r = 0}Â
speed = 0Â
bg:Destroy()Â
bv:Destroy()Â
plr.Character.Humanoid.PlatformStand = falseÂ
endÂ
mouse.KeyDown:connect(function(key)Â
if key:lower() == "e" thenÂ
if flying then flying = falseÂ
elseÂ
flying = trueÂ
Fly()Â
endÂ
elseif key:lower() == "w" thenÂ
ctrl.f = 1Â
elseif key:lower() == "s" thenÂ
ctrl.b = -1Â
elseif key:lower() == "a" thenÂ
ctrl.l = -1Â
elseif key:lower() == "d" thenÂ
ctrl.r = 1Â
endÂ
end)Â
mouse.KeyUp:connect(function(key)Â
if key:lower() == "w" thenÂ
ctrl.f = 0Â
elseif key:lower() == "s" thenÂ
ctrl.b = 0Â
elseif key:lower() == "a" thenÂ
ctrl.l = 0Â
elseif key:lower() == "d" thenÂ
ctrl.r = 0Â
endÂ
end)
Fly()
Cancel
Post