fwWSAz12_1

A Roblox Fly Script

Apr 21st, 2026 (edited)
52,696
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.46 KB | Gaming | 0 0
  1. local Players = game:GetService("Players")
  2. local UIS = game:GetService("UserInputService")
  3. local RunService = game:GetService("RunService")
  4. local TweenService = game:GetService("TweenService")
  5. local Lighting = game:GetService("Lighting")
  6.  
  7. local player = Players.LocalPlayer
  8.  
  9. local gui = Instance.new("ScreenGui")
  10. gui.Parent = game.CoreGui
  11. gui.Name = "GUI"
  12.  
  13. local frame = Instance.new("Frame", gui)
  14. frame.Size = UDim2.new(0,240,0,140)
  15. frame.Position = UDim2.new(0.4,0,0.4,0)
  16. frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
  17. frame.BackgroundTransparency = 0.3
  18. Instance.new("UICorner", frame)
  19.  
  20. local stroke = Instance.new("UIStroke", frame)
  21. stroke.Thickness = 2
  22.  
  23. local gradient = Instance.new("UIGradient", stroke)
  24. gradient.Color = ColorSequence.new({
  25. ColorSequenceKeypoint.new(0, Color3.fromRGB(255,0,0)),
  26. ColorSequenceKeypoint.new(0.2, Color3.fromRGB(255,255,0)),
  27. ColorSequenceKeypoint.new(0.4, Color3.fromRGB(0,255,0)),
  28. ColorSequenceKeypoint.new(0.6, Color3.fromRGB(0,255,255)),
  29. ColorSequenceKeypoint.new(0.8, Color3.fromRGB(0,0,255)),
  30. ColorSequenceKeypoint.new(1, Color3.fromRGB(255,0,255)),
  31. })
  32.  
  33. task.spawn(function()
  34. while true do
  35. gradient.Rotation += 2
  36. task.wait()
  37. end
  38. end)
  39.  
  40. local title = Instance.new("TextLabel", frame)
  41. title.Size = UDim2.new(1,0,0,25)
  42. title.Text = "Fly GUI v0 By Topact6"
  43. title.BackgroundTransparency = 1
  44. title.TextColor3 = Color3.new(1,1,1)
  45.  
  46. local speedBox = Instance.new("TextBox", frame)
  47. speedBox.Size = UDim2.new(0.8,0,0,25)
  48. speedBox.Position = UDim2.new(0.1,0,0.35,0)
  49. speedBox.Text = "50"
  50. speedBox.BackgroundTransparency = 0.8
  51. speedBox.TextColor3 = Color3.new(1,1,1)
  52. Instance.new("UICorner", speedBox)
  53.  
  54. local function styleButton(btn)
  55. btn.BackgroundTransparency = 0.7
  56. btn.TextColor3 = Color3.new(1,1,1)
  57.  
  58. local stroke = Instance.new("UIStroke", btn)
  59. stroke.Color = Color3.fromRGB(255, 221, 0)
  60. stroke.Thickness = 2
  61.  
  62. Instance.new("UICorner", btn)
  63. end
  64.  
  65. local toggleBtn = Instance.new("TextButton", frame)
  66. toggleBtn.Size = UDim2.new(0.8,0,0,25)
  67. toggleBtn.Position = UDim2.new(0.1,0,0.65,0)
  68. toggleBtn.Text = "Fly: Off"
  69. styleButton(toggleBtn)
  70.  
  71. local minBtn = Instance.new("TextButton", frame)
  72. minBtn.Size = UDim2.new(0,25,0,25)
  73. minBtn.Position = UDim2.new(1,-30,0,5)
  74. minBtn.Text = "-"
  75. styleButton(minBtn)
  76.  
  77. local restore = Instance.new("TextButton", gui)
  78. restore.Size = UDim2.new(0,50,0,50)
  79. restore.Position = UDim2.new(0,50,0.5,0)
  80. restore.Text = "GUI"
  81. restore.Visible = false
  82. Instance.new("UICorner", restore).CornerRadius = UDim.new(1,0)
  83.  
  84. local function makeDraggable(obj)
  85. local dragging, dragStart, startPos, moved = false
  86.  
  87. obj.InputBegan:Connect(function(input)
  88. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  89. dragging = true
  90. moved = false
  91. dragStart = input.Position
  92. startPos = obj.Position
  93. end
  94. end)
  95.  
  96. UIS.InputChanged:Connect(function(input)
  97. if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  98. local delta = input.Position - dragStart
  99. if delta.Magnitude > 5 then moved = true end
  100.  
  101. obj.Position = UDim2.new(
  102. startPos.X.Scale,
  103. startPos.X.Offset + delta.X,
  104. startPos.Y.Scale,
  105. startPos.Y.Offset + delta.Y
  106. )
  107. end
  108. end)
  109.  
  110. UIS.InputEnded:Connect(function(input)
  111. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  112. dragging = false
  113. end
  114. end)
  115.  
  116. return function() return moved end
  117. end
  118.  
  119. local restoreMoved = makeDraggable(restore)
  120. makeDraggable(frame)
  121.  
  122. minBtn.MouseButton1Click:Connect(function()
  123. TweenService:Create(frame, TweenInfo.new(0.25), {
  124. Size = UDim2.new(0,50,0,50),
  125. Position = restore.Position
  126. }):Play()
  127.  
  128. task.wait(0.25)
  129. frame.Visible = false
  130. restore.Visible = true
  131. end)
  132.  
  133. restore.MouseButton1Click:Connect(function()
  134. if restoreMoved() then return end
  135.  
  136. frame.Visible = true
  137. restore.Visible = false
  138.  
  139. frame.Size = UDim2.new(0,50,0,50)
  140. frame.Position = restore.Position
  141.  
  142. TweenService:Create(frame, TweenInfo.new(0.25), {
  143. Size = UDim2.new(0,240,0,140),
  144. Position = UDim2.new(0.4,0,0.4,0)
  145. }):Play()
  146. end)
  147.  
  148. local flying = false
  149. local bodyGyro, bodyVelocity, connection
  150.  
  151. local function startFly()
  152. local char = player.Character or player.CharacterAdded:Wait()
  153. local hrp = char:WaitForChild("HumanoidRootPart")
  154. local hum = char:WaitForChild("Humanoid")
  155.  
  156. hum.PlatformStand = true
  157.  
  158. bodyGyro = Instance.new("BodyGyro", hrp)
  159. bodyVelocity = Instance.new("BodyVelocity", hrp)
  160.  
  161. bodyGyro.MaxTorque = Vector3.new(9e9,9e9,9e9)
  162. bodyVelocity.MaxForce = Vector3.new(9e9,9e9,9e9)
  163.  
  164. local currentVelocity = Vector3.zero
  165.  
  166. flying = true
  167. toggleBtn.Text = "Fly: On"
  168.  
  169. connection = RunService.RenderStepped:Connect(function(dt)
  170. local cam = workspace.CurrentCamera
  171. local move = Vector3.zero
  172.  
  173. if UIS:IsKeyDown(Enum.KeyCode.W) then move += cam.CFrame.LookVector end
  174. if UIS:IsKeyDown(Enum.KeyCode.S) then move -= cam.CFrame.LookVector end
  175. if UIS:IsKeyDown(Enum.KeyCode.A) then move -= cam.CFrame.RightVector end
  176. if UIS:IsKeyDown(Enum.KeyCode.D) then move += cam.CFrame.RightVector end
  177.  
  178. local speed = math.clamp(tonumber(speedBox.Text) or 50,1,10000)
  179. local target = move.Magnitude > 0 and move.Unit * speed or Vector3.zero
  180.  
  181. currentVelocity = currentVelocity:Lerp(target, math.clamp(8*dt,0,1))
  182.  
  183. bodyVelocity.Velocity = currentVelocity
  184. bodyGyro.CFrame = cam.CFrame
  185. end)
  186. end
  187.  
  188. local function stopFly()
  189. flying = false
  190. toggleBtn.Text = "Fly: Off"
  191.  
  192. if connection then connection:Disconnect() end
  193. if bodyGyro then bodyGyro:Destroy() end
  194. if bodyVelocity then bodyVelocity:Destroy() end
  195.  
  196. local char = player.Character
  197. if char then
  198. local hum = char:FindFirstChild("Humanoid")
  199. if hum then
  200. hum.PlatformStand = false -- FIX: clean recovery
  201. hum:ChangeState(Enum.HumanoidStateType.Freefall)
  202. end
  203. end
  204. end
  205.  
  206. local function toggleFly()
  207. if flying then stopFly() else startFly() end
  208. end
  209.  
  210. toggleBtn.MouseButton1Click:Connect(toggleFly)
  211.  
  212. UIS.InputBegan:Connect(function(input, gpe)
  213. if not gpe and input.KeyCode == Enum.KeyCode.E then
  214. toggleFly()
  215. end
  216. end)
Advertisement
Comments
Add Comment
Please, Sign In to add comment