Eproq012

Untitled

Dec 23rd, 2024
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. local player, mouse, userInputService = game.Players.LocalPlayer, game.Players.LocalPlayerGetMouse(), gameGetService(UserInputService)
  2. local screenGui, frame = Instance.new(ScreenGui), Instance.new(Frame)
  3. screenGui.Parent, screenGui.Name = player.PlayerGui, NexUsFlyGui
  4. frame.Size, frame.Position = UDim2.new(0, 200, 0, 100), UDim2.new(0.5, -100, 0.5, -50)
  5. frame.BackgroundColor3, frame.BorderSizePixel = Color3.fromRGB(0, 0, 0), 0
  6. frame.Parent = screenGui
  7.  
  8. -- Speed slider and label
  9. local slider = Instance.new(Slider)
  10. slider.Size, slider.Position = UDim2.new(0, 180, 0, 20), UDim2.new(0, 10, 0, 50)
  11. slider.MinValue, slider.MaxValue, slider.Value = 1, 1000, 100
  12. slider.Parent = frame
  13. local speedLabel = Instance.new(TextLabel)
  14. speedLabel.Size, speedLabel.Position = UDim2.new(0, 200, 0, 20), UDim2.new(0, 10, 0, 20)
  15. speedLabel.Text, speedLabel.TextColor3 = Fly Speed 100, Color3.fromRGB(255, 255, 255)
  16. speedLabel.BackgroundTransparency = 1
  17. speedLabel.Parent = frame
  18.  
  19. -- Draggable GUI functionality
  20. local dragging, dragStart, startPos = false, nil, nil
  21. frame.InputBeganConnect(function(input)
  22. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  23. dragging, dragStart, startPos = true, input.Position, frame.Position
  24. end
  25. end)
  26. frame.InputChangedConnect(function(input)
  27. if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  28. local delta = input.Position - dragStart
  29. frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  30. end
  31. end)
  32. frame.InputEndedConnect(function(input)
  33. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  34. dragging = false
  35. end
  36. end)
  37.  
  38. -- Fly logic
  39. local flying, bodyVelocity, flySpeed = false, Instance.new(BodyVelocity), 100
  40. local function toggleFly()
  41. local char, rootPart = player.Character, player.Character and player.CharacterFindFirstChild(HumanoidRootPart)
  42. if not char or not rootPart then return end
  43. if flying then
  44. bodyVelocityDestroy()
  45. flying = false
  46. else
  47. flying = true
  48. bodyVelocity.MaxForce = Vector3.new(100000, 100000, 100000)
  49. bodyVelocity.Velocity = Vector3.new(0, 50, 0)
  50. bodyVelocity.Parent = rootPart
  51. gameGetService(RunService).HeartbeatConnect(function()
  52. if flying then
  53. bodyVelocity.Velocity = (mouse.Hit.p - rootPart.Position).unit flySpeed
  54. end
  55. end)
  56. end
  57. end
  58.  
  59. -- Toggle flying on spacebar
  60. userInputService.InputBeganConnect(function(input)
  61. if input.KeyCode == Enum.KeyCode.Space then
  62. toggleFly()
  63. end
  64. end)
  65.  
  66. -- Update speed on slider change
  67. slider.ChangedConnect(function()
  68. flySpeed = slider.Value
  69. speedLabel.Text = Fly Speed .. math.floor(flySpeed)
  70. end)
Add Comment
Please, Sign In to add comment