Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FLYING = false
- CONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
- lCONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
- SPEED = 0
- p = {}
- Players = game.Players
- local function enablef(stat)
- FLYING = stat
- local BG = Instance.new('BodyGyro')
- local BV = Instance.new('BodyVelocity')
- BG.P = 9999
- BG.Parent = game.Players.LocalPlayer.Character.PrimaryPart
- BV.Parent = game.Players.LocalPlayer.Character.PrimaryPart
- BG.maxTorque = Vector3.new(99999999, 99999999, 99999999)
- BG.cframe = game.Players.LocalPlayer.Character.PrimaryPart.CFrame
- BV.velocity = Vector3.new(0, 0, 0)
- BV.maxForce = Vector3.new(99999999, 99999999, 99999999)
- task.spawn(function()
- repeat task.wait()
- if not vfly and Players.LocalPlayer.Character:FindFirstChildOfClass('Humanoid') then
- Players.LocalPlayer.Character:FindFirstChildOfClass('Humanoid').PlatformStand = true
- end
- if CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0 or CONTROL.Q + CONTROL.E ~= 0 then
- SPEED = 50
- elseif not (CONTROL.L + CONTROL.R ~= 0 or CONTROL.F + CONTROL.B ~= 0 or CONTROL.Q + CONTROL.E ~= 0) and SPEED ~= 0 then
- SPEED = 0
- end
- if (CONTROL.L + CONTROL.R) ~= 0 or (CONTROL.F + CONTROL.B) ~= 0 or (CONTROL.Q + CONTROL.E) ~= 0 then
- BV.velocity = ((workspace.CurrentCamera.CoordinateFrame.lookVector * (CONTROL.F + CONTROL.B)) + ((workspace.CurrentCamera.CoordinateFrame * CFrame.new(CONTROL.L + CONTROL.R, (CONTROL.F + CONTROL.B + CONTROL.Q + CONTROL.E) * 0.2, 0).p) - workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
- lCONTROL = {F = CONTROL.F, B = CONTROL.B, L = CONTROL.L, R = CONTROL.R}
- elseif (CONTROL.L + CONTROL.R) == 0 and (CONTROL.F + CONTROL.B) == 0 and (CONTROL.Q + CONTROL.E) == 0 and SPEED ~= 0 then
- BV.velocity = ((workspace.CurrentCamera.CoordinateFrame.lookVector * (lCONTROL.F + lCONTROL.B)) + ((workspace.CurrentCamera.CoordinateFrame * CFrame.new(lCONTROL.L + lCONTROL.R, (lCONTROL.F + lCONTROL.B + CONTROL.Q + CONTROL.E) * 0.2, 0).p) - workspace.CurrentCamera.CoordinateFrame.p)) * SPEED
- else
- BV.velocity = Vector3.new(0, 0, 0)
- end
- BG.cframe = workspace.CurrentCamera.CoordinateFrame
- until not FLYING
- CONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
- lCONTROL = {F = 0, B = 0, L = 0, R = 0, Q = 0, E = 0}
- SPEED = 0
- BG:Destroy()
- BV:Destroy()
- if Players.LocalPlayer.Character:FindFirstChildOfClass('Humanoid') then
- Players.LocalPlayer.Character:FindFirstChildOfClass('Humanoid').PlatformStand = false
- end
- end)
- end
- game.UserInputService.InputBegan:Connect(function(i,gpe)
- if i.KeyCode == Enum.KeyCode.LeftBracket then
- if not FLYING then
- for i,v in ipairs(game.Players.LocalPlayer.Character:GetDescendants()) do
- if v:IsA("BasePart") then
- if v.CanCollide == true then
- table.insert(p,v)
- local c = v.Changed:Connect(function()
- if v.CanCollide == true then
- v.CanCollide = false
- end
- end)
- v.CanCollide = false
- coroutine.wrap(function()
- repeat task.wait() until not FLYING
- c:Disconnect()
- end)
- end
- end
- end
- else
- for i,v in pairs(p) do
- v.CanCollide = true
- end
- table.clear(p)
- end
- if FLYING then
- enablef(false)
- else
- enablef(true)
- end
- end
- end)
- iyflyspeed = 2.5
- vehicleflyspeed = 2.5
- IYMouse = Players.LocalPlayer:GetMouse()
- flyKeyDown = IYMouse.KeyDown:Connect(function(KEY)
- if KEY:lower() == 'w' then
- CONTROL.F = (vfly and vehicleflyspeed or iyflyspeed)
- elseif KEY:lower() == 's' then
- CONTROL.B = - (vfly and vehicleflyspeed or iyflyspeed)
- elseif KEY:lower() == 'a' then
- CONTROL.L = - (vfly and vehicleflyspeed or iyflyspeed)
- elseif KEY:lower() == 'd' then
- CONTROL.R = (vfly and vehicleflyspeed or iyflyspeed)
- elseif QEfly and KEY:lower() == 'e' then
- CONTROL.Q = (vfly and vehicleflyspeed or iyflyspeed)*2
- elseif QEfly and KEY:lower() == 'q' then
- CONTROL.E = -(vfly and vehicleflyspeed or iyflyspeed)*2
- end
- pcall(function() workspace.CurrentCamera.CameraType = Enum.CameraType.Track end)
- end)
- flyKeyUp = IYMouse.KeyUp:Connect(function(KEY)
- if KEY:lower() == 'w' then
- CONTROL.F = 0
- elseif KEY:lower() == 's' then
- CONTROL.B = 0
- elseif KEY:lower() == 'a' then
- CONTROL.L = 0
- elseif KEY:lower() == 'd' then
- CONTROL.R = 0
- elseif KEY:lower() == 'e' then
- CONTROL.Q = 0
- elseif KEY:lower() == 'q' then
- CONTROL.E = 0
- end
- end)
- game:GetService("RunService").PreRender:Connect(function()
- if FLYING then
- game.Players.LocalPlayer.Character.Torso.CanCollide = false
- game.Players.LocalPlayer.Character.PrimaryPart.AssemblyLinearVelocity = Vector3.zero
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement