local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local KeyCode = Enum.KeyCode.F
local HoverAnimID = "rbxassetid://89998792857721"
local FlyAnimID = "rbxassetid://109404532245455"
local WindSoundEnabled = true
local allowed = LocalPlayer:GetAttribute("FlyEnabled") or false
LocalPlayer:GetAttributeChangedSignal("FlyEnabled"):Connect(function()
allowed = LocalPlayer:GetAttribute("FlyEnabled") or false
if not allowed and Flying then
Flying = false
Flymoving.Value = false
HoverTrack:Stop()
FlyTrack:Stop()
Sound1:Stop()
TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 70}):Play()
TweenService:Create(BodyVelocity, TweenInfo.new(0.3), {Velocity = Vector3.new()}):Play()
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, true)
HRP.Running.Volume = 0.65
Humanoid:ChangeState(Enum.HumanoidStateType.Running)
BodyVelocity.Parent = Character
BodyGyro.Parent = Character
end
end)
local BodyVelocityTemplate = script:FindFirstChild("BodyVelocity") or Instance.new("BodyVelocity")
BodyVelocityTemplate.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocityTemplate.P = 3000
local BodyGyroTemplate = script:FindFirstChild("BodyGyro") or Instance.new("BodyGyro")
BodyGyroTemplate.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
BodyGyroTemplate.P = 9000
BodyGyroTemplate.D = 500
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local BodyVelocity = BodyVelocityTemplate:Clone()
local BodyGyro = BodyGyroTemplate:Clone()
BodyVelocity.Parent = Character
BodyGyro.Parent = Character
local Hover = Instance.new("Animation")
Hover.AnimationId = HoverAnimID
local Fly = Instance.new("Animation")
Fly.AnimationId = FlyAnimID
local Sound1 = Instance.new("Sound", HRP)
Sound1.SoundId = "rbxassetid://3308152153"
if not WindSoundEnabled then Sound1.Volume = 0 end
local HoverTrack = Humanoid.Animator:LoadAnimation(Hover)
local FlyTrack = Humanoid.Animator:LoadAnimation(Fly)
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Flying = false
local Flymoving = Instance.new("BoolValue")
local function getDirection()
if Humanoid.MoveDirection.Magnitude == 0 then return Vector3.new() end
local move = Camera.CFrame:VectorToObjectSpace(Humanoid.MoveDirection)
return (Camera.CFrame * CFrame.new(move.X, 0, move.Z)).p - Camera.CFrame.p
end
RunService.RenderStepped:Connect(function()
if Flying then
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
BodyGyro.CFrame = Camera.CFrame
local dir = getDirection()
if dir.Magnitude > 0 then
Flymoving.Value = true
TweenService:Create(BodyVelocity, TweenInfo.new(0.3), {Velocity = dir.Unit * 350}):Play()
else
Flymoving.Value = false
TweenService:Create(BodyVelocity, TweenInfo.new(0.3), {Velocity = Vector3.new()}):Play()
end
end
end)
Flymoving.Changed:Connect(function(val)
if val then
TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 100}):Play()
HoverTrack:Stop()
Sound1:Play()
FlyTrack:Play()
else
if Flying then
TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 70}):Play()
FlyTrack:Stop()
Sound1:Stop()
HoverTrack:Play()
end
end
end)
UIS.InputBegan:Connect(function(input, gpe)
if gpe or not allowed then return end
if input.KeyCode == KeyCode then
if not Flying then
Flying = true
HoverTrack:Play(0.1, 1, 1)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, false)
HRP.Running.Volume = 0
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
BodyVelocity.Parent = HRP
BodyGyro.Parent = HRP
else
Flying = false
Flymoving.Value = false
HoverTrack:Stop()
FlyTrack:Stop()
Sound1:Stop()
TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 70}):Play()
TweenService:Create(BodyVelocity, TweenInfo.new(0.3), {Velocity = Vector3.new()}):Play()
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, true)
HRP.Running.Volume = 0.65
Humanoid:ChangeState(Enum.HumanoidStateType.Running)
BodyVelocity.Parent = Character
BodyGyro.Parent = Character
end
end
end)
LocalPlayer.CharacterAdded:Connect(function(newChar)
Character = newChar
Humanoid = newChar:WaitForChild("Humanoid")
HRP = newChar:WaitForChild("HumanoidRootPart")
BodyVelocity = BodyVelocityTemplate:Clone()
BodyGyro = BodyGyroTemplate:Clone()
BodyVelocity.Parent = Character
BodyGyro.Parent = Character
Sound1 = Instance.new("Sound", HRP)
Sound1.SoundId = "rbxassetid://3308152153"
if not WindSoundEnabled then Sound1.Volume = 0 end
HoverTrack = Humanoid.Animator:LoadAnimation(Hover)
FlyTrack = Humanoid.Animator:LoadAnimation(Fly)
end)
To embed this project on your website, copy the following code and paste it into your website's HTML: