XxmasterT

Fly script, or exploit

Jun 1st, 2025 (edited)
2,208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.70 KB | Cybersecurity | 0 0
  1. -- Services
  2. local UIS = game:GetService("UserInputService")
  3. local RS = game:GetService("RunService")
  4. local TS = game:GetService("TweenService")
  5.  
  6. -- Player & Character references
  7. local player = game.Players.LocalPlayer
  8. local char = player.Character or player.CharacterAdded:Wait()
  9. local root = char:WaitForChild("HumanoidRootPart")
  10. local camera = workspace.CurrentCamera
  11. local humanoid = char:WaitForChild("Humanoid")
  12. local controlModule = require(player.PlayerScripts.PlayerModule.ControlModule)
  13.  
  14. -- Constantes
  15. local FLY_SPEED = 80
  16.  
  17. -- Flying state
  18. local LocalFlying = false
  19.  
  20. -- Input flags
  21. local ctrl = false
  22. local spaceKey = false
  23. local flyKey = Enum.KeyCode.F
  24.  
  25. -- Name constants for created instances
  26. local LvName = "flyLinearVelocity"
  27. local AoName = "flyAlignOrientation"
  28.  
  29. -- Zoom helper (opcional)
  30. local function Zoom(targetFOV, duration, repeatCount)
  31.     local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, repeatCount, false, 0)
  32.     local tween = TS:Create(camera, tweenInfo, { FieldOfView = targetFOV })
  33.     tween:Play()
  34. end
  35.  
  36. -- Start flying
  37. local function startFlying()
  38.     if LocalFlying then return end
  39.  
  40.     local LV = Instance.new("LinearVelocity", root)
  41.     local AO = Instance.new("AlignOrientation", root)
  42.  
  43.     LV.MaxForce = math.huge
  44.     AO.MaxTorque = math.huge
  45.     AO.Mode = Enum.OrientationAlignmentMode.OneAttachment
  46.  
  47.     LV.Attachment0 = root.RootAttachment
  48.     AO.Attachment0 = root.RootAttachment
  49.  
  50.     LV.Name = LvName
  51.     AO.Name = AoName
  52.  
  53.     humanoid.PlatformStand = true
  54.     LocalFlying = true
  55. end
  56.  
  57. -- Stop flying
  58. local function stopFlying()
  59.     if not LocalFlying then return end
  60.  
  61.     local LV = root:FindFirstChild(LvName)
  62.     local AO = root:FindFirstChild(AoName)
  63.  
  64.     humanoid.PlatformStand = false
  65.     LocalFlying = false
  66.  
  67.     if LV then LV:Destroy() end
  68.     if AO then AO:Destroy() end
  69.  
  70.     Zoom(70, 0.3, 0)
  71. end
  72.  
  73. -- Input began
  74. UIS.InputBegan:Connect(function(input, gameProcessed)
  75.     if gameProcessed then return end
  76.  
  77.     if input.KeyCode == flyKey then
  78.         if not LocalFlying then
  79.             startFlying()
  80.         else
  81.             stopFlying()
  82.         end
  83.     end
  84.  
  85.     if input.KeyCode == Enum.KeyCode.Space and LocalFlying then
  86.         spaceKey = true
  87.     end
  88.     if input.KeyCode == Enum.KeyCode.LeftControl and LocalFlying then
  89.         ctrl = true
  90.     end
  91. end)
  92.  
  93. -- Input ended
  94. UIS.InputEnded:Connect(function(input)
  95.     if input.KeyCode == Enum.KeyCode.Space then
  96.         spaceKey = false
  97.     end
  98.     if input.KeyCode == Enum.KeyCode.LeftControl then
  99.         ctrl = false
  100.     end
  101. end)
  102.  
  103. -- Main flight loop
  104. RS.Heartbeat:Connect(function()
  105.     if LocalFlying then
  106.         local LV = root:FindFirstChild(LvName)
  107.         local AO = root:FindFirstChild(AoName)
  108.         if not LV or not AO then return end
  109.  
  110.         local moveVector = controlModule:GetMoveVector()
  111.         local direction = camera.CFrame:VectorToWorldSpace(moveVector)
  112.  
  113.         if moveVector.Magnitude ~= 0 then
  114.             TS:Create(LV, TweenInfo.new(0.3), { VectorVelocity = direction * FLY_SPEED }):Play()
  115.         else
  116.             TS:Create(LV, TweenInfo.new(0.3), { VectorVelocity = Vector3.new(0, 0, 0) }):Play()
  117.             Zoom(70, 0.3, 0)
  118.         end
  119.  
  120.         if spaceKey then
  121.             LV.VectorVelocity = LV.VectorVelocity + Vector3.new(0, FLY_SPEED / 15, 0)
  122.         elseif ctrl then
  123.             LV.VectorVelocity = LV.VectorVelocity - Vector3.new(0, FLY_SPEED / 15, 0)
  124.         end
  125.  
  126.         if moveVector.Magnitude > 0 then
  127.             --AO.CFrame = CFrame.new(root.Position, root.Position + direction)
  128.             AO.RigidityEnabled = true
  129.             AO.Responsiveness = 50
  130.         else
  131.             AO.CFrame = camera.CFrame
  132.             AO.RigidityEnabled = false
  133.             AO.Responsiveness = 10
  134.         end
  135.  
  136.         AO.CFrame = camera.CFrame
  137.     end
  138. end)
  139.  
  140. -- Cleanup
  141. player.CharacterRemoving:Connect(function()
  142.     stopFlying()
  143. end)
  144.  
  145. script.Parent.AncestryChanged:Connect(function(_, parent)
  146.     if not parent then
  147.         stopFlying()
  148.     end
  149. end)
  150.  
Tags: Roblox Script fly
Advertisement
Add Comment
Please, Sign In to add comment