FAXFR

fly script roblox

Jan 3rd, 2026
5,087
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.38 KB | None | 0 0
  1. --====================================
  2. -- SIMPLE ADMIN FLY WITH SPEED GUI
  3. --====================================
  4.  
  5. local Players = game:GetService("Players")
  6. local UIS = game:GetService("UserInputService")
  7. local RunService = game:GetService("RunService")
  8.  
  9. local player = Players.LocalPlayer
  10. local character = player.Character or player.CharacterAdded:Wait()
  11. local humanoid = character:WaitForChild("Humanoid")
  12. local root = character:WaitForChild("HumanoidRootPart")
  13.  
  14. -- SETTINGS
  15. local flying = false
  16. local flySpeed = 50
  17. local SPEED_STEP = 25 -- for ' and /
  18. local GUI_SCALE_SPEED = 500 -- bar visual scale only
  19.  
  20. -- BODY MOVERS
  21. local bv, bg
  22.  
  23. --====================================
  24. -- FLY FUNCTIONS
  25. --====================================
  26.  
  27. local function startFly()
  28. flying = true
  29.  
  30. bv = Instance.new("BodyVelocity")
  31. bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
  32. bv.Velocity = Vector3.zero
  33. bv.Parent = root
  34.  
  35. bg = Instance.new("BodyGyro")
  36. bg.MaxTorque = Vector3.new(1e9, 1e9, 1e9)
  37. bg.P = 9000
  38. bg.Parent = root
  39.  
  40. humanoid.PlatformStand = true
  41. end
  42.  
  43. local function stopFly()
  44. flying = false
  45.  
  46. if bv then bv:Destroy() end
  47. if bg then bg:Destroy() end
  48.  
  49. humanoid.PlatformStand = false
  50. end
  51.  
  52. --====================================
  53. -- FLY MOVEMENT LOOP
  54. --====================================
  55.  
  56. RunService.RenderStepped:Connect(function()
  57. if not flying then return end
  58.  
  59. local cam = workspace.CurrentCamera
  60. local move = Vector3.zero
  61.  
  62. if UIS:IsKeyDown(Enum.KeyCode.W) then move += cam.CFrame.LookVector end
  63. if UIS:IsKeyDown(Enum.KeyCode.S) then move -= cam.CFrame.LookVector end
  64. if UIS:IsKeyDown(Enum.KeyCode.A) then move -= cam.CFrame.RightVector end
  65. if UIS:IsKeyDown(Enum.KeyCode.D) then move += cam.CFrame.RightVector end
  66. if UIS:IsKeyDown(Enum.KeyCode.Space) then move += Vector3.yAxis end
  67. if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then move -= Vector3.yAxis end
  68.  
  69. if move.Magnitude > 0 then
  70. move = move.Unit * flySpeed
  71. end
  72.  
  73. bv.Velocity = bv.Velocity:Lerp(move, 0.2)
  74. bg.CFrame = CFrame.new(root.Position, root.Position + cam.CFrame.LookVector)
  75. end)
  76.  
  77. --====================================
  78. -- INPUT
  79. --====================================
  80.  
  81. UIS.InputBegan:Connect(function(input, gpe)
  82. if gpe then return end
  83.  
  84. if input.KeyCode == Enum.KeyCode.F then
  85. if flying then
  86. stopFly()
  87. else
  88. startFly()
  89. end
  90. elseif input.KeyCode == Enum.KeyCode.Quote then
  91. flySpeed += SPEED_STEP
  92. updateGui()
  93. elseif input.KeyCode == Enum.KeyCode.Slash then
  94. flySpeed = math.max(1, flySpeed - SPEED_STEP)
  95. updateGui()
  96. end
  97. end)
  98.  
  99. --====================================
  100. -- SPEED GUI
  101. --====================================
  102.  
  103. local gui = Instance.new("ScreenGui")
  104. gui.Name = "FlySpeedGui"
  105. gui.ResetOnSpawn = false
  106. gui.Parent = player:WaitForChild("PlayerGui")
  107.  
  108. local frame = Instance.new("Frame", gui)
  109. frame.Size = UDim2.new(0, 60, 0, 300)
  110. frame.Position = UDim2.new(1, -80, 0.5, -150)
  111. frame.BackgroundColor3 = Color3.fromRGB(25,25,25)
  112. frame.BorderSizePixel = 0
  113.  
  114. Instance.new("UICorner", frame).CornerRadius = UDim.new(0, 12)
  115.  
  116. local barBg = Instance.new("Frame", frame)
  117. barBg.Size = UDim2.new(0, 20, 1, -50)
  118. barBg.Position = UDim2.new(0.5, -10, 0, 10)
  119. barBg.BackgroundColor3 = Color3.fromRGB(50,50,50)
  120. barBg.BorderSizePixel = 0
  121. Instance.new("UICorner", barBg).CornerRadius = UDim.new(1,0)
  122.  
  123. local bar = Instance.new("Frame", barBg)
  124. bar.AnchorPoint = Vector2.new(0,1)
  125. bar.Position = UDim2.new(0,0,1,0)
  126. bar.Size = UDim2.new(1,0,0.2,0)
  127. bar.BackgroundColor3 = Color3.fromRGB(0,170,255)
  128. bar.BorderSizePixel = 0
  129. Instance.new("UICorner", bar).CornerRadius = UDim.new(1,0)
  130.  
  131. local speedBox = Instance.new("TextBox", frame)
  132. speedBox.Size = UDim2.new(1,-10,0,30)
  133. speedBox.Position = UDim2.new(0,5,1,-35)
  134. speedBox.BackgroundColor3 = Color3.fromRGB(35,35,35)
  135. speedBox.TextColor3 = Color3.fromRGB(0,170,255)
  136. speedBox.TextScaled = true
  137. speedBox.ClearTextOnFocus = false
  138. speedBox.BorderSizePixel = 0
  139. speedBox.Text = tostring(flySpeed)
  140. Instance.new("UICorner", speedBox).CornerRadius = UDim.new(0,8)
  141.  
  142. --====================================
  143. -- GUI LOGIC
  144. --====================================
  145.  
  146. function updateGui()
  147. local percent = math.clamp(flySpeed / GUI_SCALE_SPEED, 0, 1)
  148. bar.Size = UDim2.new(1,0,percent,0)
  149. speedBox.Text = tostring(math.floor(flySpeed))
  150. end
  151.  
  152. updateGui()
  153.  
  154. local dragging = false
  155.  
  156. barBg.InputBegan:Connect(function(input)
  157. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  158. dragging = true
  159. end
  160. end)
  161.  
  162. UIS.InputEnded:Connect(function(input)
  163. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  164. dragging = false
  165. end
  166. end)
  167.  
  168. UIS.InputChanged:Connect(function(input)
  169. if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  170. local y = input.Position.Y
  171. local top = barBg.AbsolutePosition.Y
  172. local height = barBg.AbsoluteSize.Y
  173. local percent = math.clamp(1 - ((y - top) / height), 0, 1)
  174.  
  175. flySpeed = math.max(1, percent * GUI_SCALE_SPEED)
  176. updateGui()
  177. end
  178. end)
  179.  
  180. speedBox.FocusLost:Connect(function()
  181. local num = tonumber(speedBox.Text)
  182. if num and num > 0 then
  183. flySpeed = num
  184. end
  185. updateGui()
  186. end)
  187.  
  188. --====================================
  189. -- CHARACTER RESPAWN FIX
  190. --====================================
  191.  
  192. player.CharacterAdded:Connect(function(char)
  193. character = char
  194. humanoid = char:WaitForChild("Humanoid")
  195. root = char:WaitForChild("HumanoidRootPart")
  196. stopFly()
  197. end)
  198.  
Advertisement
Add Comment
Please, Sign In to add comment