-- Fly Control (Clean Version) -- LocalScript local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local RS = game:GetService("RunService") local player = Players.LocalPlayer local char, hum, hrp -- character update local function updateChar() char = player.Character or player.CharacterAdded:Wait() hum = char:WaitForChild("Humanoid") hrp = char:WaitForChild("HumanoidRootPart") end updateChar() player.CharacterAdded:Connect(updateChar) -- remove old gui if game.CoreGui:FindFirstChild("FlyGui") then game.CoreGui.FlyGui:Destroy() end -- GUI local gui = Instance.new("ScreenGui") gui.Name = "FlyGui" gui.ResetOnSpawn = false gui.Parent = game.CoreGui local main = Instance.new("Frame") main.Parent = gui main.Size = UDim2.new(0,260,0,160) main.Position = UDim2.new(0.05,0,0.4,0) main.BackgroundColor3 = Color3.fromRGB(18,18,18) main.BorderSizePixel = 0 main.Active = true Instance.new("UICorner", main).CornerRadius = UDim.new(0,10) -- drag bar local dragBar = Instance.new("Frame", main) dragBar.Size = UDim2.new(1,0,0,30) dragBar.BackgroundColor3 = Color3.fromRGB(25,25,25) dragBar.BorderSizePixel = 0 dragBar.Active = true Instance.new("UICorner", dragBar).CornerRadius = UDim.new(0,10) local title = Instance.new("TextLabel", dragBar) title.Size = UDim2.new(1,0,1,0) title.BackgroundTransparency = 1 title.Text = "Fly Control" title.Font = Enum.Font.GothamMedium title.TextColor3 = Color3.fromRGB(220,220,220) title.TextScaled = true -- drag logic local dragging, dragStart, startPos dragBar.InputBegan:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then dragging = true dragStart = i.Position startPos = main.Position end end) UIS.InputEnded:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then dragging = false end end) UIS.InputChanged:Connect(function(i) if dragging and i.UserInputType == Enum.UserInputType.MouseMovement then local delta = i.Position - dragStart main.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end end) -- Fly button local flyButton = Instance.new("TextButton", main) flyButton.Size = UDim2.new(0.9,0,0,32) flyButton.Position = UDim2.new(0.05,0,0,40) flyButton.Text = "Fly: OFF (B)" flyButton.Font = Enum.Font.GothamMedium flyButton.TextColor3 = Color3.fromRGB(255,80,80) flyButton.BackgroundColor3 = Color3.fromRGB(30,30,30) flyButton.BorderSizePixel = 0 Instance.new("UICorner", flyButton) -- Speed text local speedText = Instance.new("TextLabel", main) speedText.Size = UDim2.new(0.9,0,0,20) speedText.Position = UDim2.new(0.05,0,0,80) speedText.BackgroundTransparency = 1 speedText.Font = Enum.Font.Gotham speedText.TextColor3 = Color3.fromRGB(200,200,200) speedText.Text = "Speed: 60" speedText.TextScaled = true -- Slider local bar = Instance.new("Frame", main) bar.Size = UDim2.new(0.9,0,0,6) bar.Position = UDim2.new(0.05,0,0,115) bar.BackgroundColor3 = Color3.fromRGB(45,45,45) bar.BorderSizePixel = 0 Instance.new("UICorner", bar) local knob = Instance.new("Frame", bar) knob.Size = UDim2.new(0,12,1,0) knob.Position = UDim2.new(0.12,0,0,0) knob.BackgroundColor3 = Color3.fromRGB(0,170,255) knob.BorderSizePixel = 0 Instance.new("UICorner", knob) -- Fly system local flying = false local flySpeed = 60 local flyBV, flyBG local moveDir = {W=0,S=0,A=0,D=0} UIS.InputBegan:Connect(function(i,g) if g then return end if i.KeyCode == Enum.KeyCode.B then flyButton:Activate() end if i.KeyCode == Enum.KeyCode.W then moveDir.W = 1 end if i.KeyCode == Enum.KeyCode.S then moveDir.S = 1 end if i.KeyCode == Enum.KeyCode.A then moveDir.A = 1 end if i.KeyCode == Enum.KeyCode.D then moveDir.D = 1 end end) UIS.InputEnded:Connect(function(i) if i.KeyCode == Enum.KeyCode.W then moveDir.W = 0 end if i.KeyCode == Enum.KeyCode.S then moveDir.S = 0 end if i.KeyCode == Enum.KeyCode.A then moveDir.A = 0 end if i.KeyCode == Enum.KeyCode.D then moveDir.D = 0 end end) -- Slider logic local sliding = false knob.InputBegan:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then sliding = true end end) UIS.InputEnded:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then sliding = false end end) UIS.InputChanged:Connect(function(i) if sliding and i.UserInputType == Enum.UserInputType.MouseMovement then local p = math.clamp((i.Position.X - bar.AbsolutePosition.X) / bar.AbsoluteSize.X, 0, 1) knob.Position = UDim2.new(p,0,0,0) flySpeed = math.floor(10 + p * 490) speedText.Text = "Speed: "..flySpeed end end) -- Toggle fly local function toggleFly() flying = not flying if flying then flyButton.Text = "Fly: ON (B)" flyButton.TextColor3 = Color3.fromRGB(80,255,80) hum.PlatformStand = true flyBV = Instance.new("BodyVelocity", hrp) flyBV.MaxForce = Vector3.new(1e9,1e9,1e9) flyBG = Instance.new("BodyGyro", hrp) flyBG.MaxTorque = Vector3.new(1e9,1e9,1e9) flyBG.P = 1e5 RS:BindToRenderStep("FlyMove", 1, function() local cam = workspace.CurrentCamera local move = Vector3.new( moveDir.D - moveDir.A, 0, moveDir.S - moveDir.W ) if move.Magnitude > 0 then flyBV.Velocity = cam.CFrame:VectorToWorldSpace(move).Unit * flySpeed else flyBV.Velocity = Vector3.zero end flyBG.CFrame = cam.CFrame end) else flyButton.Text = "Fly: OFF (B)" flyButton.TextColor3 = Color3.fromRGB(255,80,80) RS:UnbindFromRenderStep("FlyMove") if flyBV then flyBV:Destroy() end if flyBG then flyBG:Destroy() end hum.PlatformStand = false end end flyButton.MouseButton1Click:Connect(toggleFly)