Advertisement
aesnike

GUI (GPT)

Oct 26th, 2024 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.46 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local gui = nil
  3. local mainFrame = nil
  4. local closeButton = nil
  5.  
  6. -- Function to create the GUI
  7. local function createGui()
  8. if gui then gui:Destroy() end
  9.  
  10. local ScreenGui = Instance.new("ScreenGui")
  11. local MainFrame = Instance.new("Frame")
  12. local CloseButton = Instance.new("TextButton")
  13.  
  14. ScreenGui.Name = "PersistentGUI"
  15. ScreenGui.ResetOnSpawn = false
  16. ScreenGui.Parent = player.PlayerGui
  17.  
  18. CloseButton.Size = UDim2.new(0, 100, 0, 25)
  19. CloseButton.Position = UDim2.new(0.5, -50, 0, 10)
  20. CloseButton.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
  21. CloseButton.Text = "Close"
  22. CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  23. CloseButton.Font = Enum.Font.SourceSansBold
  24. CloseButton.TextSize = 14
  25. CloseButton.Parent = ScreenGui
  26. CloseButton.ZIndex = 10
  27.  
  28. MainFrame.Size = UDim2.new(0.2, 0, 0.6, 0)
  29. MainFrame.Position = UDim2.new(0.5, -100, 0, 80)
  30. MainFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  31. MainFrame.BackgroundTransparency = 0.5
  32. MainFrame.BorderSizePixel = 0
  33. MainFrame.ClipsDescendants = true
  34. MainFrame.Visible = true
  35. MainFrame.ZIndex = 1
  36. MainFrame.Parent = ScreenGui
  37.  
  38. local UIListLayout = Instance.new("UIListLayout")
  39. UIListLayout.Parent = MainFrame
  40. UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  41. UIListLayout.Padding = UDim.new(0, 20)
  42. UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
  43.  
  44. -- Function to create toggle buttons
  45. local function createToggleButton(number, name, onClick)
  46. local button = Instance.new("TextButton")
  47. button.Size = UDim2.new(0.7, 0, 0, 30)
  48. button.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  49. button.Text = name
  50. button.TextColor3 = Color3.fromRGB(255, 255, 255)
  51. button.Font = Enum.Font.SourceSansBold
  52. button.TextSize = 14
  53. button.LayoutOrder = number
  54. button.Parent = MainFrame
  55. button.ZIndex = 2
  56.  
  57. local corner = Instance.new("UICorner")
  58. corner.CornerRadius = UDim.new(0.3, 0)
  59. corner.Parent = button
  60.  
  61. local isEnabled = false
  62.  
  63. button.MouseButton1Click:Connect(function()
  64. isEnabled = not isEnabled
  65. button.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(0, 0, 0)
  66. onClick(isEnabled)
  67. end)
  68.  
  69. return button
  70. end
  71.  
  72. -- Kill Aura Function
  73. local killAuraActive = false
  74. local killAuraLoop = nil
  75. local function toggleKillAura(isEnabled)
  76. killAuraActive = isEnabled
  77. if isEnabled then
  78. if not killAuraLoop then
  79. killAuraLoop = spawn(function()
  80. while killAuraActive do
  81. local args = {
  82. [1] = {
  83. [1] = {
  84. ["animationLength"] = 0,
  85. ["sentAt"] = tick()
  86. },
  87. [2] = "G"
  88. }
  89. }
  90. game:GetService("ReplicatedStorage").dataRemoteEvent:FireServer(unpack(args))
  91. wait(0)
  92. end
  93. end)
  94. end
  95. else
  96. killAuraActive = false
  97. killAuraLoop = nil
  98. end
  99. end
  100.  
  101. -- TP Function
  102. local tpActive = false
  103. local tpLoop = nil
  104. local function toggleTP(isEnabled)
  105. tpActive = isEnabled
  106. if isEnabled then
  107. if not tpLoop then
  108. tpLoop = spawn(function()
  109. while tpActive do
  110. local Players = game:GetService("Players")
  111. local LocalPlayer = Players.LocalPlayer
  112. local Character = LocalPlayer.Character
  113. local targetNPC
  114.  
  115. local function findNearestNPC()
  116. local nearestNPC = nil
  117. local nearestDistance = math.huge
  118.  
  119. if not Character or not Character.HumanoidRootPart then return end
  120.  
  121. for _, folder in ipairs(workspace:GetChildren()) do
  122. if folder:IsA("Folder") then
  123. for _, child in ipairs(folder:GetChildren()) do
  124. if child:FindFirstChild("enemyFolder") then
  125. for _, npc in ipairs(child.enemyFolder:GetChildren()) do
  126. if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
  127. local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
  128. if distance < nearestDistance then
  129. nearestDistance = distance
  130. nearestNPC = npc
  131. end
  132. end
  133. end
  134. end
  135. end
  136. end
  137. end
  138. return nearestNPC
  139. end
  140.  
  141. targetNPC = findNearestNPC()
  142. if Character and Character:FindFirstChild("HumanoidRootPart") and targetNPC and targetNPC:FindFirstChild("HumanoidRootPart") then
  143. local npcPosition = targetNPC.HumanoidRootPart.Position
  144. local offset = Vector3.new(0, 9, 0)
  145. local cframe = CFrame.new(npcPosition + offset, npcPosition)
  146. Character.HumanoidRootPart.CFrame = cframe
  147. end
  148. wait(0.5)
  149. end
  150. end)
  151. end
  152. else
  153. tpActive = false
  154. tpLoop = nil
  155. end
  156. end
  157.  
  158. -- Auto-Ability Function
  159. local abilityActive = false
  160. local abilityLoop = nil
  161. local function toggleAbility(isEnabled)
  162. abilityActive = isEnabled
  163. if isEnabled then
  164. if not abilityLoop then
  165. abilityLoop = spawn(function()
  166. local VirtualInputManager = game:GetService("VirtualInputManager")
  167. local lastKeyPress = 0
  168. local keyPressCooldown = 0.5
  169.  
  170. while abilityActive do
  171. local Character = player.Character
  172. if Character and Character:FindFirstChild("HumanoidRootPart") then
  173. local function isNearMobs(range)
  174. for _, folder in ipairs(workspace:GetChildren()) do
  175. if folder:IsA("Folder") then
  176. for _, child in ipairs(folder:GetChildren()) do
  177. if child:FindFirstChild("enemyFolder") then
  178. for _, npc in ipairs(child.enemyFolder:GetChildren()) do
  179. if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
  180. local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
  181. if distance <= range then
  182. return true
  183. end
  184. end
  185. end
  186. end
  187. end
  188. end
  189. end
  190. return false
  191. end
  192.  
  193. if isNearMobs(20) and tick() - lastKeyPress >= keyPressCooldown then
  194. VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.E, false, nil)
  195. task.wait()
  196. VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.E, false, nil)
  197.  
  198. VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.Q, false, nil)
  199. task.wait()
  200. VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.Q, false, nil)
  201.  
  202. lastKeyPress = tick()
  203. end
  204. end
  205. wait(0.1)
  206. end
  207. end)
  208. end
  209. else
  210. abilityActive = false
  211. abilityLoop = nil
  212. end
  213. end
  214.  
  215. -- Coin-TP Function
  216. local coinTPActive = false
  217. local coinTPLoop = nil
  218. local function toggleCoinTP(isEnabled)
  219. coinTPActive = isEnabled
  220. if isEnabled then
  221. if not coinTPLoop then
  222. coinTPLoop = spawn(function()
  223. while coinTPActive do
  224. local function waitForCoin()
  225. while not workspace:FindFirstChild("Coin") or not workspace.Coin:FindFirstChild("Coin") do
  226. wait(2)
  227. if not coinTPActive then return nil end
  228. end
  229. return workspace.Coin.Coin
  230. end
  231.  
  232. local coin = waitForCoin()
  233. if coin and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  234. local offset = Vector3.new(0, 8, 0)
  235. for i = 1, 20 do
  236. if not coinTPActive then break end
  237. player.Character.HumanoidRootPart.CFrame = CFrame.new(coin.Position + offset)
  238. wait(0.01)
  239. end
  240. end
  241. wait(0.1)
  242. end
  243. end)
  244. end
  245. else
  246. coinTPActive = false
  247. coinTPLoop = nil
  248. end
  249. end
  250.  
  251. -- Create all buttons
  252. createToggleButton(1, "Kill Aura", toggleKillAura)
  253. createToggleButton(2, "TP", toggleTP)
  254. createToggleButton(3, "Auto-Ability", toggleAbility)
  255. createToggleButton(4, "Coin-TP", toggleCoinTP)
  256.  
  257. -- Add padding at the top of the frame
  258. local UIPadding = Instance.new("UIPadding")
  259. UIPadding.Parent = MainFrame
  260. UIPadding.PaddingTop = UDim.new(0, 20)
  261.  
  262. -- Rounded corners
  263. local cornerFrame = Instance.new("UICorner")
  264. cornerFrame.CornerRadius = UDim.new(0.05, 0)
  265. cornerFrame.Parent = MainFrame
  266.  
  267. local cornerButton = Instance.new("UICorner")
  268. cornerButton.CornerRadius = UDim.new(0.3, 0)
  269. cornerButton.Parent = CloseButton
  270.  
  271. -- Store references
  272. gui = ScreenGui
  273. mainFrame = MainFrame
  274. closeButton = CloseButton
  275.  
  276. -- Toggle function
  277. local function toggleGui()
  278. MainFrame.Visible = not MainFrame.Visible
  279. CloseButton.Text = MainFrame.Visible and "Close" or "Open"
  280. end
  281.  
  282. -- Make elements draggable independently
  283. local function makeDraggable(gui)
  284. local dragging = false
  285. local dragStart = nil
  286. local startPos = nil
  287. local dragInput = nil
  288.  
  289. gui.InputBegan:Connect(function(input)
  290. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  291. dragging = true
  292. dragStart = input.Position
  293. startPos = gui.Position
  294.  
  295. input.Changed:Connect(function()
  296. if input.UserInputState == Enum.UserInputState.End then
  297. dragging = false
  298. end
  299. end)
  300. end
  301. end)
  302.  
  303. gui.InputChanged:Connect(function(input)
  304. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  305. dragInput = input
  306. end
  307. end)
  308.  
  309. game:GetService("UserInputService").InputChanged:Connect(function(input)
  310. if input == dragInput and dragging then
  311. local delta = input.Position - dragStart
  312. gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  313. end
  314. end)
  315. end
  316.  
  317. makeDraggable(CloseButton)
  318. makeDraggable(MainFrame)
  319. CloseButton.MouseButton1Click:Connect(toggleGui)
  320. end
  321.  
  322. -- Create initial GUI
  323. createGui()
  324.  
  325. -- Handle character respawning
  326. player.CharacterAdded:Connect(function()
  327. if not gui or not gui.Parent then
  328. createGui()
  329. end
  330. end)
  331.  
  332. -- Handle player removal
  333. player.AncestryChanged:Connect(function(_, parent)
  334. if not parent then
  335. gui:Destroy()
  336. end
  337. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement