Chaseycoil

Flylie - Universal Fly GUI

Aug 14th, 2025
24,465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.49 KB | Source Code | 0 0
  1. -- Fly GUI "Flylie" with fully draggable main and minimized button
  2. local Players = game:GetService("Players")
  3. local LocalPlayer = Players.LocalPlayer
  4. local UserInputService = game:GetService("UserInputService")
  5. local RunService = game:GetService("RunService")
  6.  
  7. -- Fly variables
  8. local flying = false
  9. local speed = 50
  10. local maxSpeed = 250
  11. local keysPressed = {}
  12. local bv, bg
  13.  
  14. -- Fly functions
  15. local function startFly()
  16.     local char = LocalPlayer.Character
  17.     if not char then return end
  18.     local hrp = char:FindFirstChild("HumanoidRootPart")
  19.     local humanoid = char:FindFirstChildOfClass("Humanoid")
  20.     if not hrp or not humanoid then return end
  21.     humanoid.PlatformStand = true
  22.  
  23.     if hrp:FindFirstChild("BodyVelocity") then hrp.BodyVelocity:Destroy() end
  24.     if hrp:FindFirstChild("BodyGyro") then hrp.BodyGyro:Destroy() end
  25.  
  26.     bv = Instance.new("BodyVelocity")
  27.     bv.MaxForce = Vector3.new(1e5,1e5,1e5)
  28.     bv.Velocity = Vector3.new(0,0,0)
  29.     bv.Parent = hrp
  30.  
  31.     bg = Instance.new("BodyGyro")
  32.     bg.MaxTorque = Vector3.new(1e5,1e5,1e5)
  33.     bg.CFrame = hrp.CFrame
  34.     bg.Parent = hrp
  35. end
  36.  
  37. local function stopFly()
  38.     local char = LocalPlayer.Character
  39.     if not char then return end
  40.     local hrp = char:FindFirstChild("HumanoidRootPart")
  41.     local humanoid = char:FindFirstChildOfClass("Humanoid")
  42.     if humanoid then humanoid.PlatformStand = false end
  43.     if bv then bv:Destroy() end
  44.     if bg then bg:Destroy() end
  45. end
  46.  
  47. -- GUI setup
  48. local screenGui = Instance.new("ScreenGui", game:GetService("CoreGui"))
  49.  
  50. -- Main frame
  51. local frame = Instance.new("Frame")
  52. frame.Size = UDim2.new(0,250,0,150)
  53. frame.Position = UDim2.new(0,50,0,50)
  54. frame.BackgroundColor3 = Color3.fromRGB(40,40,40)
  55. frame.BorderSizePixel = 0
  56. frame.Parent = screenGui
  57.  
  58. -- Top bar
  59. local topBar = Instance.new("Frame")
  60. topBar.Size = UDim2.new(1,0,0,25)
  61. topBar.Position = UDim2.new(0,0,0,0)
  62. topBar.BackgroundColor3 = Color3.fromRGB(30,30,30)
  63. topBar.Parent = frame
  64.  
  65. -- Title
  66. local title = Instance.new("TextLabel")
  67. title.Size = UDim2.new(1, -50,1,0)
  68. title.Position = UDim2.new(0,5,0,0)
  69. title.BackgroundTransparency = 1
  70. title.Text = "Flylie"
  71. title.TextColor3 = Color3.new(1,1,1)
  72. title.TextScaled = true
  73. title.Font = Enum.Font.SourceSansBold
  74. title.Parent = topBar
  75.  
  76. -- Close button
  77. local closeBtn = Instance.new("TextButton")
  78. closeBtn.Size = UDim2.new(0,25,0,25)
  79. closeBtn.Position = UDim2.new(1,-25,0,0)
  80. closeBtn.Text = "X"
  81. closeBtn.TextColor3 = Color3.new(1,0,0)
  82. closeBtn.BackgroundColor3 = Color3.fromRGB(50,50,50)
  83. closeBtn.Parent = topBar
  84.  
  85. -- Minimize button
  86. local minBtn = Instance.new("TextButton")
  87. minBtn.Size = UDim2.new(0,25,0,25)
  88. minBtn.Position = UDim2.new(1,-50,0,0)
  89. minBtn.Text = "-"
  90. minBtn.TextColor3 = Color3.new(1,1,0)
  91. minBtn.BackgroundColor3 = Color3.fromRGB(50,50,50)
  92. minBtn.Parent = topBar
  93.  
  94. -- Fly button
  95. local flyBtn = Instance.new("TextButton")
  96. flyBtn.Size = UDim2.new(0,200,0,40)
  97. flyBtn.Position = UDim2.new(0,25,0,35)
  98. flyBtn.Text = "Fly: OFF"
  99. flyBtn.BackgroundColor3 = Color3.fromRGB(50,50,50)
  100. flyBtn.TextColor3 = Color3.new(1,1,1)
  101. flyBtn.Font = Enum.Font.SourceSansBold
  102. flyBtn.TextScaled = true
  103. flyBtn.Parent = frame
  104.  
  105. -- Speed Label
  106. local speedLabel = Instance.new("TextLabel")
  107. speedLabel.Size = UDim2.new(0,200,0,30)
  108. speedLabel.Position = UDim2.new(0,25,0,80)
  109. speedLabel.BackgroundTransparency = 1
  110. speedLabel.TextColor3 = Color3.new(1,1,1)
  111. speedLabel.Font = Enum.Font.SourceSans
  112. speedLabel.TextScaled = true
  113. speedLabel.Text = "Speed: "..speed
  114. speedLabel.Parent = frame
  115.  
  116. -- Speed TextBox
  117. local speedBox = Instance.new("TextBox")
  118. speedBox.Size = UDim2.new(0,200,0,30)
  119. speedBox.Position = UDim2.new(0,25,0,115)
  120. speedBox.BackgroundColor3 = Color3.fromRGB(50,50,50)
  121. speedBox.TextColor3 = Color3.new(1,1,1)
  122. speedBox.Font = Enum.Font.SourceSansBold
  123. speedBox.TextScaled = true
  124. speedBox.Text = tostring(speed)
  125. speedBox.ClearTextOnFocus = false
  126. speedBox.Parent = frame
  127.  
  128. -- Minimized button
  129. local miniBtn = Instance.new("TextButton")
  130. miniBtn.Size = UDim2.new(0,60,0,60)
  131. miniBtn.Position = UDim2.new(0,50,0,50)
  132. miniBtn.Text = "Flylie"
  133. miniBtn.TextScaled = true
  134. miniBtn.Font = Enum.Font.SourceSansBold
  135. miniBtn.TextColor3 = Color3.new(1,1,1)
  136. miniBtn.BackgroundColor3 = Color3.fromRGB(40,40,40)
  137. miniBtn.Visible = false
  138. miniBtn.Parent = screenGui
  139.  
  140. -- Dragging variables
  141. local draggingFrame = false
  142. local dragOffset = Vector2.new(0,0)
  143. local draggingMini = false
  144. local miniOffset = Vector2.new(0,0)
  145.  
  146. -- Top bar drag
  147. topBar.InputBegan:Connect(function(input)
  148.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  149.         draggingFrame = true
  150.         local mousePos = input.Position
  151.         local framePos = frame.Position
  152.         dragOffset = Vector2.new(mousePos.X - framePos.X.Offset, mousePos.Y - framePos.Y.Offset)
  153.     end
  154. end)
  155.  
  156. topBar.InputEnded:Connect(function(input)
  157.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  158.         draggingFrame = false
  159.     end
  160. end)
  161.  
  162. UserInputService.InputChanged:Connect(function(input)
  163.     if draggingFrame and input.UserInputType == Enum.UserInputType.MouseMovement then
  164.         frame.Position = UDim2.new(0,input.Position.X - dragOffset.X,0,input.Position.Y - dragOffset.Y)
  165.     elseif draggingMini and input.UserInputType == Enum.UserInputType.MouseMovement then
  166.         miniBtn.Position = UDim2.new(0,input.Position.X - miniOffset.X,0,input.Position.Y - miniOffset.Y)
  167.     end
  168. end)
  169.  
  170. -- Mini button drag
  171. miniBtn.InputBegan:Connect(function(input)
  172.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  173.         draggingMini = true
  174.         local mousePos = input.Position
  175.         local btnPos = miniBtn.Position
  176.         miniOffset = Vector2.new(mousePos.X - btnPos.X.Offset, mousePos.Y - btnPos.Y.Offset)
  177.     end
  178. end)
  179. miniBtn.InputEnded:Connect(function(input)
  180.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  181.         draggingMini = false
  182.     end
  183. end)
  184.  
  185. -- Fly toggle
  186. flyBtn.MouseButton1Click:Connect(function()
  187.     flying = not flying
  188.     flyBtn.Text = "Fly: "..(flying and "ON" or "OFF")
  189.     if flying then startFly() else stopFly() end
  190. end)
  191.  
  192. -- Speed input
  193. speedBox.FocusLost:Connect(function()
  194.     local val = tonumber(speedBox.Text)
  195.     if val then
  196.         if val > maxSpeed then val = maxSpeed end
  197.         if val < 1 then val = 1 end
  198.         speed = val
  199.         speedLabel.Text = "Speed: "..speed
  200.         speedBox.Text = tostring(speed)
  201.     else
  202.         speedBox.Text = tostring(speed)
  203.     end
  204. end)
  205.  
  206. -- Close button
  207. closeBtn.MouseButton1Click:Connect(function()
  208.     screenGui:Destroy()
  209. end)
  210.  
  211. -- Minimize button
  212. minBtn.MouseButton1Click:Connect(function()
  213.     frame.Visible = false
  214.     miniBtn.Visible = true
  215. end)
  216.  
  217. -- Restore from minimized
  218. miniBtn.MouseButton1Click:Connect(function()
  219.     frame.Visible = true
  220.     miniBtn.Visible = false
  221. end)
  222.  
  223. -- Track keys
  224. UserInputService.InputBegan:Connect(function(input, processed)
  225.     if processed then return end
  226.     if input.UserInputType == Enum.UserInputType.Keyboard then
  227.         keysPressed[input.KeyCode] = true
  228.     end
  229. end)
  230. UserInputService.InputEnded:Connect(function(input)
  231.     if input.UserInputType == Enum.UserInputType.Keyboard then
  232.         keysPressed[input.KeyCode] = false
  233.     end
  234. end)
  235.  
  236. -- Fly loop
  237. RunService.RenderStepped:Connect(function()
  238.     if flying and bv and bg and LocalPlayer.Character then
  239.         local hrp = LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
  240.         if hrp then
  241.             local cam = workspace.CurrentCamera
  242.             local moveVec = Vector3.new(0,0,0)
  243.             if keysPressed[Enum.KeyCode.W] then moveVec = moveVec + Vector3.new(0,0,-1) end
  244.             if keysPressed[Enum.KeyCode.S] then moveVec = moveVec + Vector3.new(0,0,1) end
  245.             if keysPressed[Enum.KeyCode.A] then moveVec = moveVec + Vector3.new(-1,0,0) end
  246.             if keysPressed[Enum.KeyCode.D] then moveVec = moveVec + Vector3.new(1,0,0) end
  247.             if keysPressed[Enum.KeyCode.Space] then moveVec = moveVec + Vector3.new(0,1,0) end
  248.             if keysPressed[Enum.KeyCode.LeftControl] then moveVec = moveVec + Vector3.new(0,-1,0) end
  249.  
  250.             if moveVec.Magnitude > 0 then
  251.                 local camCF = CFrame.new(Vector3.new(), cam.CFrame.LookVector)
  252.                 local relative = (camCF:VectorToWorldSpace(moveVec)).Unit * speed
  253.                 bv.Velocity = relative
  254.             else
  255.                 bv.Velocity = Vector3.new(0,0,0)
  256.             end
  257.  
  258.             bg.CFrame = CFrame.new(hrp.Position, hrp.Position + cam.CFrame.LookVector)
  259.         end
  260.     end
  261. end)
  262.  
Advertisement
Add Comment
Please, Sign In to add comment