Advertisement
SigmaBoy456

Vehicle fly GUI v2

Oct 5th, 2024 (edited)
40,357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. local setting = {
  2. time = getgenv().setting_stopflytime or 3
  3. }
  4.  
  5. local player = game.Players.LocalPlayer
  6. local character = player.Character
  7. local localroot = character:WaitForChild("HumanoidRootPart")
  8.  
  9. local function getVER()
  10. for _, v in pairs(localroot:GetDescendants()) do
  11. if v:IsA("BodyVelocity") then
  12. return v
  13. end
  14. end
  15. end
  16.  
  17. local function getGY()
  18. for _, v in pairs(localroot:GetDescendants()) do
  19. if v:IsA("BodyGyro") then
  20. return v
  21. end
  22. end
  23. end
  24.  
  25. local function stopFLY()
  26. if getVER() and getGY() then
  27. getVER():Destroy()
  28. getGY():Destroy()
  29. end
  30. end
  31.  
  32. local Cam = workspace.CurrentCamera
  33.  
  34. -- Update GUI
  35. if game.CoreGui:FindFirstChild("Vehicle GUI") then
  36. game.CoreGui:FindFirstChild("Vehicle GUI"):Destroy()
  37. end
  38. -- Update Player
  39. game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
  40. character = char
  41. localroot = character:WaitForChild("HumanoidRootPart")
  42. end)
  43.  
  44. local GUI = Instance.new("ScreenGui", game.CoreGui)
  45. GUI.Name = "Vehicle GUI"
  46.  
  47. local mainF = Instance.new("Frame", GUI)
  48. mainF.Size = UDim2.new(0, 100, 0, 100)
  49. mainF.Name = "my Frame"
  50. mainF.Position = UDim2.new(0, 30, 0, 0)
  51. mainF.BackgroundColor3 = Color3.new(1, 1, 1)
  52. mainF.Active = true
  53. mainF.Draggable = true
  54.  
  55. local title = Instance.new("TextLabel", mainF)
  56. title.Name = "my Title"
  57. title.Size = UDim2.new(0, 100, 0, 20)
  58. title.Position = UDim2.new(0, 0, 0, 0)
  59. title.BackgroundColor3 = Color3.new(1, 1, 1)
  60. title.Text = "Vehicle Fly v2"
  61. title.TextScaled = true
  62. title.TextWrapped = true
  63.  
  64. local flyButton = Instance.new("TextButton", mainF)
  65. flyButton.Size = UDim2.new(0, 100, 0, 30)
  66. flyButton.Position = UDim2.new(0, 0, 0, 20)
  67. flyButton.Name = "My Button to fly"
  68. flyButton.BackgroundColor3 = Color3.fromRGB(31, 255, 0)
  69. flyButton.Text = "Fly foward"
  70. flyButton.TextScaled = true
  71. flyButton.TextWrapped = true
  72.  
  73. local speed_INPUT = Instance.new("TextBox", mainF)
  74. speed_INPUT.Size = UDim2.new(0, 100, 0, 20)
  75. speed_INPUT.Position = UDim2.new(0, 0, 0, 50)
  76. speed_INPUT.BackgroundColor3 = Color3.new(1, 1, 1)
  77. speed_INPUT.Name = "Speed Input"
  78. speed_INPUT.Text = "Input you Fly Speed here"
  79. speed_INPUT.TextScaled = true
  80. speed_INPUT.TextWrapped = true
  81. -- setup BodyVelocity and BodyGyro
  82.  
  83. local ver = Instance.new("BodyVelocity", localroot)
  84. local bg = Instance.new("BodyGyro", localroot)
  85.  
  86. -- Event
  87. flyButton.MouseButton1Click:Connect(function()
  88. if localroot then
  89. if not localroot:FindFirstChildOfClass("BodyVelocity") and not localroot:FindFirstChildOfClass("BodyGyro") then
  90. ver = Instance.new("BodyVelocity", localroot)
  91. bg = Instance.new("BodyGyro", localroot)
  92. end
  93. bg.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  94. bg.D = 5000
  95. bg.P = 5000
  96. bg.CFrame = Cam.CFrame
  97. ver.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  98. ver.P = 50000
  99. ver.Velocity = Cam.CFrame.LookVector * tonumber(speed_INPUT.Text)
  100. wait(setting.time)
  101. ver.P = 0
  102. ver.Velocity = Vector3.new()
  103. end
  104. end)
  105.  
  106. local stopFly = Instance.new("TextButton", mainF)
  107. stopFly.Size = UDim2.new(0, 100, 0, 20)
  108. stopFly.Position = UDim2.new(0, 0, 0, 100)
  109. stopFly.Name = "Stop fly funny"
  110. stopFly.BackgroundColor3 = Color3.fromRGB(255, 17, 0)
  111. stopFly.Text = "Stop Fly"
  112. stopFly.TextScaled = true
  113. stopFly.TextWrapped = true
  114.  
  115. -- Event
  116. stopFly.MouseButton1Click:Connect(function()
  117. if localroot:FindFirstChildOfClass("BodyVelocity") and localroot:FindFirstChildOfClass("BodyGyro") then
  118. repeat
  119. stopFLY()
  120. until localroot:FindFirstChildOfClass("BodyVelocity") == nil and localroot:FindFirstChildOfClass("BodGyro") == nil
  121. end
  122. end)
  123.  
  124. local backward = Instance.new("TextButton", mainF)
  125. backward.Size = UDim2.new(0, 100, 0, 20)
  126. backward.Position = UDim2.new(0, 0, 0, 70)
  127. backward.BackgroundColor3 = Color3.new(1, 1, 1)
  128. backward.Name = "Backward"
  129. backward.Text = "Fly Backward"
  130. backward.TextScaled = true
  131. backward.TextWrapped = true
  132.  
  133. -- Event
  134. backward.MouseButton1Click:Connect(function()
  135. if localroot then
  136. if not localroot:FindFirstChildOfClass("BodyVelocity") and not localroot:FindFirstChildOfClass("BodyGyro") then
  137. ver = Instance.new("BodyVelocity", localroot)
  138. bg = Instance.new("BodyGyro", localroot)
  139. end
  140. bg.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  141. bg.D = 5000
  142. bg.P = 50000
  143. bg.CFrame = Cam.CFrame
  144. ver.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  145. ver.P = 50000
  146. ver.Velocity = Cam.CFrame.LookVector * tonumber(-speed_INPUT.Text)
  147. wait(setting.time)
  148. ver.Velocity = Vector3.new()
  149. end
  150. end)
  151.  
  152. local close = Instance.new("TextButton", GUI)
  153. close.Size = UDim2.new(0, 100, 0, 50)
  154. close.Position = UDim2.new(0, 0, 0, 200)
  155. close.Name = "Close the GUI"
  156. close.BackgroundColor3 = Color3.new(1, 1, 1)
  157. close.Text = "Close GUI"
  158. close.TextScaled = true
  159. close.TextWrapped = true
  160.  
  161. -- Event
  162. close.MouseButton1Click:Connect(function()
  163. if mainF.Visible then
  164. mainF.Visible = false
  165. close.Text = "Open GUI"
  166. elseif not mainF.Visible then
  167. mainF.Visible = true
  168. close.Text = "Close GUI"
  169. end
  170. end)
  171.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement