Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fly GUI "Flylie" with fully draggable main and minimized button
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- -- Fly variables
- local flying = false
- local speed = 50
- local maxSpeed = 250
- local keysPressed = {}
- local bv, bg
- -- Fly functions
- local function startFly()
- local char = LocalPlayer.Character
- if not char then return end
- local hrp = char:FindFirstChild("HumanoidRootPart")
- local humanoid = char:FindFirstChildOfClass("Humanoid")
- if not hrp or not humanoid then return end
- humanoid.PlatformStand = true
- if hrp:FindFirstChild("BodyVelocity") then hrp.BodyVelocity:Destroy() end
- if hrp:FindFirstChild("BodyGyro") then hrp.BodyGyro:Destroy() end
- bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(1e5,1e5,1e5)
- bv.Velocity = Vector3.new(0,0,0)
- bv.Parent = hrp
- bg = Instance.new("BodyGyro")
- bg.MaxTorque = Vector3.new(1e5,1e5,1e5)
- bg.CFrame = hrp.CFrame
- bg.Parent = hrp
- end
- local function stopFly()
- local char = LocalPlayer.Character
- if not char then return end
- local hrp = char:FindFirstChild("HumanoidRootPart")
- local humanoid = char:FindFirstChildOfClass("Humanoid")
- if humanoid then humanoid.PlatformStand = false end
- if bv then bv:Destroy() end
- if bg then bg:Destroy() end
- end
- -- GUI setup
- local screenGui = Instance.new("ScreenGui", game:GetService("CoreGui"))
- -- Main frame
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(0,250,0,150)
- frame.Position = UDim2.new(0,50,0,50)
- frame.BackgroundColor3 = Color3.fromRGB(40,40,40)
- frame.BorderSizePixel = 0
- frame.Parent = screenGui
- -- Top bar
- local topBar = Instance.new("Frame")
- topBar.Size = UDim2.new(1,0,0,25)
- topBar.Position = UDim2.new(0,0,0,0)
- topBar.BackgroundColor3 = Color3.fromRGB(30,30,30)
- topBar.Parent = frame
- -- Title
- local title = Instance.new("TextLabel")
- title.Size = UDim2.new(1, -50,1,0)
- title.Position = UDim2.new(0,5,0,0)
- title.BackgroundTransparency = 1
- title.Text = "Flylie"
- title.TextColor3 = Color3.new(1,1,1)
- title.TextScaled = true
- title.Font = Enum.Font.SourceSansBold
- title.Parent = topBar
- -- Close button
- local closeBtn = Instance.new("TextButton")
- closeBtn.Size = UDim2.new(0,25,0,25)
- closeBtn.Position = UDim2.new(1,-25,0,0)
- closeBtn.Text = "X"
- closeBtn.TextColor3 = Color3.new(1,0,0)
- closeBtn.BackgroundColor3 = Color3.fromRGB(50,50,50)
- closeBtn.Parent = topBar
- -- Minimize button
- local minBtn = Instance.new("TextButton")
- minBtn.Size = UDim2.new(0,25,0,25)
- minBtn.Position = UDim2.new(1,-50,0,0)
- minBtn.Text = "-"
- minBtn.TextColor3 = Color3.new(1,1,0)
- minBtn.BackgroundColor3 = Color3.fromRGB(50,50,50)
- minBtn.Parent = topBar
- -- Fly button
- local flyBtn = Instance.new("TextButton")
- flyBtn.Size = UDim2.new(0,200,0,40)
- flyBtn.Position = UDim2.new(0,25,0,35)
- flyBtn.Text = "Fly: OFF"
- flyBtn.BackgroundColor3 = Color3.fromRGB(50,50,50)
- flyBtn.TextColor3 = Color3.new(1,1,1)
- flyBtn.Font = Enum.Font.SourceSansBold
- flyBtn.TextScaled = true
- flyBtn.Parent = frame
- -- Speed Label
- local speedLabel = Instance.new("TextLabel")
- speedLabel.Size = UDim2.new(0,200,0,30)
- speedLabel.Position = UDim2.new(0,25,0,80)
- speedLabel.BackgroundTransparency = 1
- speedLabel.TextColor3 = Color3.new(1,1,1)
- speedLabel.Font = Enum.Font.SourceSans
- speedLabel.TextScaled = true
- speedLabel.Text = "Speed: "..speed
- speedLabel.Parent = frame
- -- Speed TextBox
- local speedBox = Instance.new("TextBox")
- speedBox.Size = UDim2.new(0,200,0,30)
- speedBox.Position = UDim2.new(0,25,0,115)
- speedBox.BackgroundColor3 = Color3.fromRGB(50,50,50)
- speedBox.TextColor3 = Color3.new(1,1,1)
- speedBox.Font = Enum.Font.SourceSansBold
- speedBox.TextScaled = true
- speedBox.Text = tostring(speed)
- speedBox.ClearTextOnFocus = false
- speedBox.Parent = frame
- -- Minimized button
- local miniBtn = Instance.new("TextButton")
- miniBtn.Size = UDim2.new(0,60,0,60)
- miniBtn.Position = UDim2.new(0,50,0,50)
- miniBtn.Text = "Flylie"
- miniBtn.TextScaled = true
- miniBtn.Font = Enum.Font.SourceSansBold
- miniBtn.TextColor3 = Color3.new(1,1,1)
- miniBtn.BackgroundColor3 = Color3.fromRGB(40,40,40)
- miniBtn.Visible = false
- miniBtn.Parent = screenGui
- -- Dragging variables
- local draggingFrame = false
- local dragOffset = Vector2.new(0,0)
- local draggingMini = false
- local miniOffset = Vector2.new(0,0)
- -- Top bar drag
- topBar.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- draggingFrame = true
- local mousePos = input.Position
- local framePos = frame.Position
- dragOffset = Vector2.new(mousePos.X - framePos.X.Offset, mousePos.Y - framePos.Y.Offset)
- end
- end)
- topBar.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- draggingFrame = false
- end
- end)
- UserInputService.InputChanged:Connect(function(input)
- if draggingFrame and input.UserInputType == Enum.UserInputType.MouseMovement then
- frame.Position = UDim2.new(0,input.Position.X - dragOffset.X,0,input.Position.Y - dragOffset.Y)
- elseif draggingMini and input.UserInputType == Enum.UserInputType.MouseMovement then
- miniBtn.Position = UDim2.new(0,input.Position.X - miniOffset.X,0,input.Position.Y - miniOffset.Y)
- end
- end)
- -- Mini button drag
- miniBtn.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- draggingMini = true
- local mousePos = input.Position
- local btnPos = miniBtn.Position
- miniOffset = Vector2.new(mousePos.X - btnPos.X.Offset, mousePos.Y - btnPos.Y.Offset)
- end
- end)
- miniBtn.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- draggingMini = false
- end
- end)
- -- Fly toggle
- flyBtn.MouseButton1Click:Connect(function()
- flying = not flying
- flyBtn.Text = "Fly: "..(flying and "ON" or "OFF")
- if flying then startFly() else stopFly() end
- end)
- -- Speed input
- speedBox.FocusLost:Connect(function()
- local val = tonumber(speedBox.Text)
- if val then
- if val > maxSpeed then val = maxSpeed end
- if val < 1 then val = 1 end
- speed = val
- speedLabel.Text = "Speed: "..speed
- speedBox.Text = tostring(speed)
- else
- speedBox.Text = tostring(speed)
- end
- end)
- -- Close button
- closeBtn.MouseButton1Click:Connect(function()
- screenGui:Destroy()
- end)
- -- Minimize button
- minBtn.MouseButton1Click:Connect(function()
- frame.Visible = false
- miniBtn.Visible = true
- end)
- -- Restore from minimized
- miniBtn.MouseButton1Click:Connect(function()
- frame.Visible = true
- miniBtn.Visible = false
- end)
- -- Track keys
- UserInputService.InputBegan:Connect(function(input, processed)
- if processed then return end
- if input.UserInputType == Enum.UserInputType.Keyboard then
- keysPressed[input.KeyCode] = true
- end
- end)
- UserInputService.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- keysPressed[input.KeyCode] = false
- end
- end)
- -- Fly loop
- RunService.RenderStepped:Connect(function()
- if flying and bv and bg and LocalPlayer.Character then
- local hrp = LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
- if hrp then
- local cam = workspace.CurrentCamera
- local moveVec = Vector3.new(0,0,0)
- if keysPressed[Enum.KeyCode.W] then moveVec = moveVec + Vector3.new(0,0,-1) end
- if keysPressed[Enum.KeyCode.S] then moveVec = moveVec + Vector3.new(0,0,1) end
- if keysPressed[Enum.KeyCode.A] then moveVec = moveVec + Vector3.new(-1,0,0) end
- if keysPressed[Enum.KeyCode.D] then moveVec = moveVec + Vector3.new(1,0,0) end
- if keysPressed[Enum.KeyCode.Space] then moveVec = moveVec + Vector3.new(0,1,0) end
- if keysPressed[Enum.KeyCode.LeftControl] then moveVec = moveVec + Vector3.new(0,-1,0) end
- if moveVec.Magnitude > 0 then
- local camCF = CFrame.new(Vector3.new(), cam.CFrame.LookVector)
- local relative = (camCF:VectorToWorldSpace(moveVec)).Unit * speed
- bv.Velocity = relative
- else
- bv.Velocity = Vector3.new(0,0,0)
- end
- bg.CFrame = CFrame.new(hrp.Position, hrp.Position + cam.CFrame.LookVector)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment