Created
July 25, 2020 23:50
-
-
Save ferothefox/6231c7e42b1ad776c2c05e4d05f9d6fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do | |
if v:IsA("Model") then | |
Player = game.Players.LocalPlayer | |
local flying = false | |
local flyenabled = false | |
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 = 200 | |
local speed = 100 | |
function Fly() | |
local torso = v.SeatDriver | |
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() | |
--Player.Character.Humanoid.PlatformStand = true | |
if ctrl.l + ctrl.r ~= 0 or ctrl.f + ctrl.b ~= 0 then | |
speed = speed+.2+(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 = 1000 | |
end | |
end | |
if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then | |
bv.velocity = ((game:GetService("Workspace").CurrentCamera.CoordinateFrame.lookVector * (ctrl.f+ctrl.b)) + ((game:GetService("Workspace").CurrentCamera.CoordinateFrame * CFrame.new(ctrl.l+ctrl.r,(ctrl.f+ctrl.b)*.2,0).p) - game:GetService("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:GetService("Workspace").CurrentCamera.CoordinateFrame.lookVector * (lastctrl.f+lastctrl.b)) + ((game:GetService("Workspace").CurrentCamera.CoordinateFrame * CFrame.new(lastctrl.l+lastctrl.r,(lastctrl.f+lastctrl.b)*.2,0).p) - game:GetService("Workspace").CurrentCamera.CoordinateFrame.p))*speed | |
else | |
bv.velocity = Vector3.new(0,0.1,0) | |
end | |
bg.cframe = game:GetService("Workspace").CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad((ctrl.f+ctrl.b)*4*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 = 1000 | |
bg:Destroy() | |
bv:Destroy() | |
Player.Character.Humanoid.PlatformStand = false | |
end | |
Player:GetMouse().KeyDown:connect(function(key) | |
if key:lower() == "t" 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) | |
Player:GetMouse().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) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment