Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fly Script with Admin-style Features & Flying Animation
- -- Press F to toggle flight mode - Enhanced turning speed
- -- Configuration
- local flySpeed = 50
- local turnSpeed = 120 -- Increased turning speed
- local flyEnabled = false
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- local rootPart = character:WaitForChild("HumanoidRootPart")
- local animate = character:WaitForChild("Animate")
- -- Flight setup
- local bodyVelocity
- local bodyGyro
- local flightAnimationTrack
- local flyingAnimation
- -- Load flying animation
- local function loadFlyingAnimation()
- if character and humanoid then
- -- Create flying animation
- flyingAnimation = Instance.new("Animation")
- flyingAnimation.AnimationId = "rbxassetid://3541114300" -- Flying animation
- -- Load the animation track
- flightAnimationTrack = humanoid:LoadAnimation(flyingAnimation)
- flightAnimationTrack.Priority = Enum.AnimationPriority.Action
- flightAnimationTrack.Looped = true
- end
- end
- -- Initialize animation
- loadFlyingAnimation()
- -- Toggle flight function
- local function toggleFlight()
- flyEnabled = not flyEnabled
- if flyEnabled then
- -- Stop default animations
- if animate then
- for _, track in pairs(animate:GetChildren()) do
- if track:IsA("AnimationTrack") then
- track:Stop()
- end
- end
- end
- -- Play flying animation
- if flightAnimationTrack then
- flightAnimationTrack:Play()
- flightAnimationTrack:AdjustSpeed(1.2) -- Slightly faster flying animation
- end
- -- Create flight controls
- bodyVelocity = Instance.new("BodyVelocity")
- bodyGyro = Instance.new("BodyGyro")
- bodyVelocity.Velocity = Vector3.new(0, 0, 0)
- bodyVelocity.MaxForce = Vector3.new(40000, 40000, 40000)
- bodyVelocity.P = 10000
- bodyGyro.MaxTorque = Vector3.new(40000, 40000, 40000)
- bodyGyro.P = 8000
- bodyGyro.D = 100
- bodyGyro.CFrame = rootPart.CFrame
- bodyVelocity.Parent = rootPart
- bodyGyro.Parent = rootPart
- humanoid.PlatformStand = true
- -- Adjust humanoid for flying state
- humanoid.WalkSpeed = 0
- humanoid.JumpPower = 0
- -- Notify player
- game.StarterGui:SetCore("SendNotification", {
- Title = "🦅 Flight Mode",
- Text = "ENABLED\nWASD to move | F to disable",
- Duration = 3,
- Icon = "rbxassetid://4483345998"
- })
- -- Flight movement loop
- local flightConnection
- flightConnection = game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
- if not flyEnabled or not character or not rootPart then
- flightConnection:Disconnect()
- return
- end
- local camera = workspace.CurrentCamera
- local moveDirection = Vector3.new(0, 0, 0)
- -- Get camera look vector for movement direction
- local lookVector = camera.CFrame.LookVector
- local rightVector = camera.CFrame.RightVector
- -- Forward/Backward (W/S)
- if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.W) then
- moveDirection = moveDirection + (lookVector * flySpeed)
- end
- if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.S) then
- moveDirection = moveDirection - (lookVector * flySpeed)
- end
- -- Left/Right (A/D)
- if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.A) then
- moveDirection = moveDirection - (rightVector * flySpeed)
- end
- if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.D) then
- moveDirection = moveDirection + (rightVector * flySpeed)
- end
- -- Up/Down (Space/LeftShift or Q/E)
- if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Space) or
- game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.E) then
- moveDirection = moveDirection + Vector3.new(0, flySpeed, 0)
- end
- if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) or
- game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Q) then
- moveDirection = moveDirection - Vector3.new(0, flySpeed, 0)
- end
- -- Apply movement if any direction is pressed
- if moveDirection.Magnitude > 0 then
- bodyVelocity.Velocity = moveDirection
- -- Adjust animation speed based on movement speed
- if flightAnimationTrack then
- local speedMultiplier = 0.8 + (moveDirection.Magnitude / flySpeed) * 0.4
- flightAnimationTrack:AdjustSpeed(speedMultiplier)
- end
- else
- bodyVelocity.Velocity = Vector3.new(0, 0, 0)
- -- Slow animation when hovering
- if flightAnimationTrack then
- flightAnimationTrack:AdjustSpeed(0.6)
- end
- end
- -- Update gyro for turning
- bodyGyro.CFrame = CFrame.new(rootPart.Position, rootPart.Position + lookVector)
- end)
- else
- -- Stop flying animation
- if flightAnimationTrack then
- flightAnimationTrack:Stop()
- end
- -- Reset animations
- if animate then
- for _, track in pairs(animate:GetChildren()) do
- if track:IsA("AnimationTrack") then
- track:Play()
- end
- end
- end
- -- Disable flight
- if bodyVelocity then
- bodyVelocity:Destroy()
- bodyVelocity = nil
- end
- if bodyGyro then
- bodyGyro:Destroy()
- bodyGyro = nil
- end
- humanoid.PlatformStand = false
- -- Reset humanoid state
- humanoid.WalkSpeed = 16
- humanoid.JumpPower = 50
- humanoid:ChangeState(Enum.HumanoidStateType.Landed)
- -- Play landing animation
- if character:FindFirstChild("Humanoid") then
- humanoid:ChangeState(Enum.HumanoidStateType.Landed)
- end
- -- Notify player
- game.StarterGui:SetCore("SendNotification", {
- Title = "🦅 Flight Mode",
- Text = "DISABLED",
- Duration = 3,
- Icon = "rbxassetid://4483345998"
- })
- end
- end
- -- Enhanced mouse control for turning while flying
- local mouse = player:GetMouse()
- local lastMousePosition
- mouse.Button2Down:Connect(function()
- if flyEnabled then
- lastMousePosition = Vector2.new(mouse.X, mouse.Y)
- -- Mouse movement for camera control while flying
- local mouseMoveConnection
- mouseMoveConnection = mouse.Move:Connect(function()
- if not flyEnabled or not lastMousePosition then
- mouseMoveConnection:Disconnect()
- return
- end
- local delta = Vector2.new(mouse.X - lastMousePosition.X, mouse.Y - lastMousePosition.Y)
- lastMousePosition = Vector2.new(mouse.X, mouse.Y)
- -- Apply rotation based on mouse movement
- if bodyGyro then
- local currentCFrame = bodyGyro.CFrame
- local rotation = CFrame.fromEulerAnglesYXZ(
- -delta.Y * turnSpeed * 0.001,
- -delta.X * turnSpeed * 0.001,
- 0
- )
- bodyGyro.CFrame = currentCFrame * rotation
- end
- end)
- -- Disconnect when mouse button is released
- mouse.Button2Up:Connect(function()
- if mouseMoveConnection then
- mouseMoveConnection:Disconnect()
- end
- lastMousePosition = nil
- end)
- end
- end)
- -- Key press detection
- local uis = game:GetService("UserInputService")
- uis.InputBegan:Connect(function(input, processed)
- if not processed and input.KeyCode == Enum.KeyCode.F then
- toggleFlight()
- end
- end)
- -- Character reconnection handling
- player.CharacterAdded:Connect(function(newCharacter)
- character = newCharacter
- humanoid = character:WaitForChild("Humanoid")
- rootPart = character:WaitForChild("HumanoidRootPart")
- animate = character:WaitForChild("Animate")
- -- Reset flight state on character change
- flyEnabled = false
- if bodyVelocity then bodyVelocity:Destroy() end
- if bodyGyro then bodyGyro:Destroy() end
- -- Reload animation for new character
- loadFlyingAnimation()
- end)
- -- Adjust fly speed with key binds
- uis.InputBegan:Connect(function(input, processed)
- if not processed and flyEnabled then
- if input.KeyCode == Enum.KeyCode.PageUp then
- turnSpeed = math.min(turnSpeed + 20, 200)
- game.StarterGui:SetCore("SendNotification", {
- Title = "Turn Speed",
- Text = "Increased to: " .. turnSpeed,
- Duration = 2
- })
- elseif input.KeyCode == Enum.KeyCode.PageDown then
- turnSpeed = math.max(turnSpeed - 20, 20)
- game.StarterGui:SetCore("SendNotification", {
- Title = "Turn Speed",
- Text = "Decreased to: " .. turnSpeed,
- Duration = 2
- })
- elseif input.KeyCode == Enum.KeyCode.Equals then
- flySpeed = math.min(flySpeed + 10, 100)
- game.StarterGui:SetCore("SendNotification", {
- Title = "Fly Speed",
- Text = "Increased to: " .. flySpeed,
- Duration = 2
- })
- elseif input.KeyCode == Enum.KeyCode.Minus then
- flySpeed = math.max(flySpeed - 10, 10)
- game.StarterGui:SetCore("SendNotification", {
- Title = "Fly Speed",
- Text = "Decreased to: " .. flySpeed,
- Duration = 2
- })
- end
- end
- end)
- -- Optional: Visual effects when flying
- local function createFlightEffects()
- if not character then return end
- -- Create particle effects for flying
- local flightParticles = Instance.new("ParticleEmitter")
- flightParticles.Parent = rootPart
- flightParticles.Color = ColorSequence.new(Color3.fromRGB(100, 149, 237))
- flightParticles.Size = NumberSequence.new(0.5)
- flightParticles.Transparency = NumberSequence.new(0.5)
- flightParticles.Lifetime = NumberRange.new(0.5)
- flightParticles.Rate = 20
- flightParticles.Speed = NumberRange.new(2)
- flightParticles.VelocitySpread = 180
- flightParticles.Acceleration = Vector3.new(0, -10, 0)
- return flightParticles
- end
- -- Toggle effects based on preference
- local useEffects = false
- local flightEffects
- -- Initial notification
- game.StarterGui:SetCore("SendNotification", {
- Title = "🦅 Flight Script Loaded",
- Text = "Press F to toggle flight\nRight click + drag for camera control\nPageUp/PageDown = Turn Speed\n+/- = Fly Speed",
- Duration = 6,
- Icon = "rbxassetid://6559555125"
- })
- print("Enhanced fly script with animation loaded!")
- print("Turn Speed: " .. turnSpeed)
- print("Fly Speed: " .. flySpeed)
Advertisement