Advertisement
Kelsondre69

Fly gui script (FIRST JUMP AND POINT WHERE YOU WANT TO GO WITH YOUR CAMERA!)

May 30th, 2024
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. -- Create ScreenGui
  2. local screenGui = Instance.new("ScreenGui")
  3. screenGui.Name = "FlyGui"
  4. screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  5.  
  6. -- Create Frame
  7. local frame = Instance.new("Frame")
  8. frame.Size = UDim2.new(0.3, 0, 0.3, 0)
  9. frame.Position = UDim2.new(0.35, 0, 0.35, 0)
  10. frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  11. frame.BackgroundTransparency = 0.5
  12. frame.Active = true
  13. frame.Draggable = true
  14. frame.Parent = screenGui
  15.  
  16. -- Create Enable Fly Button
  17. local enableFlyButton = Instance.new("TextButton")
  18. enableFlyButton.Size = UDim2.new(0.8, 0, 0.3, 0)
  19. enableFlyButton.Position = UDim2.new(0.1, 0, 0.1, 0)
  20. enableFlyButton.Text = "Enable Fly"
  21. enableFlyButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  22. enableFlyButton.TextScaled = true
  23. enableFlyButton.Parent = frame
  24.  
  25. -- Create Disable Fly Button
  26. local disableFlyButton = Instance.new("TextButton")
  27. disableFlyButton.Size = UDim2.new(0.8, 0, 0.3, 0)
  28. disableFlyButton.Position = UDim2.new(0.1, 0, 0.5, 0)
  29. disableFlyButton.Text = "Disable Fly"
  30. disableFlyButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  31. disableFlyButton.TextScaled = true
  32. disableFlyButton.Parent = frame
  33.  
  34. -- Variables for flying
  35. local flying = false
  36. local speed = 50
  37. local player = game.Players.LocalPlayer
  38. local character = player.Character or player.CharacterAdded:Wait()
  39. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  40.  
  41. -- Function to start flying
  42. local function startFly()
  43. if flying then return end
  44. flying = true
  45. local bodyVelocity = Instance.new("BodyVelocity")
  46. bodyVelocity.Velocity = Vector3.new(0, 0, 0)
  47. bodyVelocity.MaxForce = Vector3.new(4000, 4000, 4000)
  48. bodyVelocity.Parent = humanoidRootPart
  49.  
  50. local bodyGyro = Instance.new("BodyGyro")
  51. bodyGyro.MaxTorque = Vector3.new(4000, 4000, 4000)
  52. bodyGyro.CFrame = humanoidRootPart.CFrame
  53. bodyGyro.Parent = humanoidRootPart
  54.  
  55. spawn(function()
  56. while flying do
  57. local camera = game.Workspace.CurrentCamera
  58. local direction = camera.CFrame.lookVector
  59. bodyVelocity.Velocity = direction * speed
  60. bodyGyro.CFrame = camera.CFrame
  61. wait()
  62. end
  63. bodyVelocity:Destroy()
  64. bodyGyro:Destroy()
  65. end)
  66. end
  67.  
  68. -- Function to stop flying
  69. local function stopFly()
  70. flying = false
  71. end
  72.  
  73. -- Button functions
  74. enableFlyButton.MouseButton1Click:Connect(startFly)
  75. disableFlyButton.MouseButton1Click:Connect(stopFly)
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement