Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local UIS = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local TweenService = game:GetService("TweenService")
- local Lighting = game:GetService("Lighting")
- local player = Players.LocalPlayer
- local gui = Instance.new("ScreenGui")
- gui.Parent = game.CoreGui
- gui.Name = "GUI"
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0,240,0,140)
- frame.Position = UDim2.new(0.4,0,0.4,0)
- frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
- frame.BackgroundTransparency = 0.3
- Instance.new("UICorner", frame)
- local stroke = Instance.new("UIStroke", frame)
- stroke.Thickness = 2
- local gradient = Instance.new("UIGradient", stroke)
- gradient.Color = ColorSequence.new({
- ColorSequenceKeypoint.new(0, Color3.fromRGB(255,0,0)),
- ColorSequenceKeypoint.new(0.2, Color3.fromRGB(255,255,0)),
- ColorSequenceKeypoint.new(0.4, Color3.fromRGB(0,255,0)),
- ColorSequenceKeypoint.new(0.6, Color3.fromRGB(0,255,255)),
- ColorSequenceKeypoint.new(0.8, Color3.fromRGB(0,0,255)),
- ColorSequenceKeypoint.new(1, Color3.fromRGB(255,0,255)),
- })
- task.spawn(function()
- while true do
- gradient.Rotation += 2
- task.wait()
- end
- end)
- local title = Instance.new("TextLabel", frame)
- title.Size = UDim2.new(1,0,0,25)
- title.Text = "Fly GUI v0 By Topact6"
- title.BackgroundTransparency = 1
- title.TextColor3 = Color3.new(1,1,1)
- local speedBox = Instance.new("TextBox", frame)
- speedBox.Size = UDim2.new(0.8,0,0,25)
- speedBox.Position = UDim2.new(0.1,0,0.35,0)
- speedBox.Text = "50"
- speedBox.BackgroundTransparency = 0.8
- speedBox.TextColor3 = Color3.new(1,1,1)
- Instance.new("UICorner", speedBox)
- local function styleButton(btn)
- btn.BackgroundTransparency = 0.7
- btn.TextColor3 = Color3.new(1,1,1)
- local stroke = Instance.new("UIStroke", btn)
- stroke.Color = Color3.fromRGB(255, 221, 0)
- stroke.Thickness = 2
- Instance.new("UICorner", btn)
- end
- local toggleBtn = Instance.new("TextButton", frame)
- toggleBtn.Size = UDim2.new(0.8,0,0,25)
- toggleBtn.Position = UDim2.new(0.1,0,0.65,0)
- toggleBtn.Text = "Fly: Off"
- styleButton(toggleBtn)
- local minBtn = Instance.new("TextButton", frame)
- minBtn.Size = UDim2.new(0,25,0,25)
- minBtn.Position = UDim2.new(1,-30,0,5)
- minBtn.Text = "-"
- styleButton(minBtn)
- local restore = Instance.new("TextButton", gui)
- restore.Size = UDim2.new(0,50,0,50)
- restore.Position = UDim2.new(0,50,0.5,0)
- restore.Text = "GUI"
- restore.Visible = false
- Instance.new("UICorner", restore).CornerRadius = UDim.new(1,0)
- local function makeDraggable(obj)
- local dragging, dragStart, startPos, moved = false
- obj.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = true
- moved = false
- dragStart = input.Position
- startPos = obj.Position
- end
- end)
- UIS.InputChanged:Connect(function(input)
- if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
- local delta = input.Position - dragStart
- if delta.Magnitude > 5 then moved = true end
- obj.Position = UDim2.new(
- startPos.X.Scale,
- startPos.X.Offset + delta.X,
- startPos.Y.Scale,
- startPos.Y.Offset + delta.Y
- )
- end
- end)
- UIS.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = false
- end
- end)
- return function() return moved end
- end
- local restoreMoved = makeDraggable(restore)
- makeDraggable(frame)
- minBtn.MouseButton1Click:Connect(function()
- TweenService:Create(frame, TweenInfo.new(0.25), {
- Size = UDim2.new(0,50,0,50),
- Position = restore.Position
- }):Play()
- task.wait(0.25)
- frame.Visible = false
- restore.Visible = true
- end)
- restore.MouseButton1Click:Connect(function()
- if restoreMoved() then return end
- frame.Visible = true
- restore.Visible = false
- frame.Size = UDim2.new(0,50,0,50)
- frame.Position = restore.Position
- TweenService:Create(frame, TweenInfo.new(0.25), {
- Size = UDim2.new(0,240,0,140),
- Position = UDim2.new(0.4,0,0.4,0)
- }):Play()
- end)
- local flying = false
- local bodyGyro, bodyVelocity, connection
- local function startFly()
- local char = player.Character or player.CharacterAdded:Wait()
- local hrp = char:WaitForChild("HumanoidRootPart")
- local hum = char:WaitForChild("Humanoid")
- hum.PlatformStand = true
- bodyGyro = Instance.new("BodyGyro", hrp)
- bodyVelocity = Instance.new("BodyVelocity", hrp)
- bodyGyro.MaxTorque = Vector3.new(9e9,9e9,9e9)
- bodyVelocity.MaxForce = Vector3.new(9e9,9e9,9e9)
- local currentVelocity = Vector3.zero
- flying = true
- toggleBtn.Text = "Fly: On"
- connection = RunService.RenderStepped:Connect(function(dt)
- local cam = workspace.CurrentCamera
- local move = Vector3.zero
- if UIS:IsKeyDown(Enum.KeyCode.W) then move += cam.CFrame.LookVector end
- if UIS:IsKeyDown(Enum.KeyCode.S) then move -= cam.CFrame.LookVector end
- if UIS:IsKeyDown(Enum.KeyCode.A) then move -= cam.CFrame.RightVector end
- if UIS:IsKeyDown(Enum.KeyCode.D) then move += cam.CFrame.RightVector end
- local speed = math.clamp(tonumber(speedBox.Text) or 50,1,10000)
- local target = move.Magnitude > 0 and move.Unit * speed or Vector3.zero
- currentVelocity = currentVelocity:Lerp(target, math.clamp(8*dt,0,1))
- bodyVelocity.Velocity = currentVelocity
- bodyGyro.CFrame = cam.CFrame
- end)
- end
- local function stopFly()
- flying = false
- toggleBtn.Text = "Fly: Off"
- if connection then connection:Disconnect() end
- if bodyGyro then bodyGyro:Destroy() end
- if bodyVelocity then bodyVelocity:Destroy() end
- local char = player.Character
- if char then
- local hum = char:FindFirstChild("Humanoid")
- if hum then
- hum.PlatformStand = false -- FIX: clean recovery
- hum:ChangeState(Enum.HumanoidStateType.Freefall)
- end
- end
- end
- local function toggleFly()
- if flying then stopFly() else startFly() end
- end
- toggleBtn.MouseButton1Click:Connect(toggleFly)
- UIS.InputBegan:Connect(function(input, gpe)
- if not gpe and input.KeyCode == Enum.KeyCode.E then
- toggleFly()
- end
- end)
Advertisement