Advertisement
aesnike

MAIN-GUI

Oct 26th, 2024 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.66 KB | None | 0 0
  1.  
  2. local player = game.Players.LocalPlayer
  3. local gui = nil
  4. local mainFrame = nil
  5. local closeButton = nil
  6.  
  7. -- Function to create the GUI
  8. local function createGui()
  9. if gui then gui:Destroy() end
  10.  
  11. local ScreenGui = Instance.new("ScreenGui")
  12. local MainFrame = Instance.new("Frame")
  13. local CloseButton = Instance.new("TextButton")
  14.  
  15. ScreenGui.Name = "PersistentGUI"
  16. ScreenGui.ResetOnSpawn = false
  17. ScreenGui.Parent = player.PlayerGui
  18.  
  19. CloseButton.Size = UDim2.new(0, 100, 0, 25)
  20. CloseButton.Position = UDim2.new(0.5, -50, 0, 10)
  21. CloseButton.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
  22. CloseButton.Text = "Close"
  23. CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  24. CloseButton.Font = Enum.Font.SourceSansBold
  25. CloseButton.TextSize = 14
  26. CloseButton.Parent = ScreenGui
  27. CloseButton.ZIndex = 10
  28.  
  29. MainFrame.Size = UDim2.new(0.2, 0, 0.6, 0)
  30. MainFrame.Position = UDim2.new(0.5, -100, 0, 80)
  31. MainFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  32. MainFrame.BackgroundTransparency = 0.5
  33. MainFrame.BorderSizePixel = 0
  34. MainFrame.ClipsDescendants = true
  35. MainFrame.Visible = true
  36. MainFrame.ZIndex = 1
  37. MainFrame.Parent = ScreenGui
  38.  
  39. local UIListLayout = Instance.new("UIListLayout")
  40. UIListLayout.Parent = MainFrame
  41. UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  42. UIListLayout.Padding = UDim.new(0, 20)
  43. UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
  44.  
  45. -- Function to create toggle buttons
  46. local function createToggleButton(number, name, onClick)
  47. local button = Instance.new("TextButton")
  48. button.Size = UDim2.new(0.7, 0, 0, 30)
  49. button.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  50. button.Text = name
  51. button.TextColor3 = Color3.fromRGB(255, 255, 255)
  52. button.Font = Enum.Font.SourceSansBold
  53. button.TextSize = 14
  54. button.LayoutOrder = number
  55. button.Parent = MainFrame
  56. button.ZIndex = 2
  57.  
  58. local corner = Instance.new("UICorner")
  59. corner.CornerRadius = UDim.new(0.3, 0)
  60. corner.Parent = button
  61.  
  62. -- Load saved state
  63. local isEnabled = buttonStates[name] or false
  64. button.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(0, 0, 0)
  65.  
  66. -- If button was previously enabled, activate it
  67. if isEnabled then
  68. onClick(true)
  69. end
  70.  
  71. button.MouseButton1Click:Connect(function()
  72. isEnabled = not isEnabled
  73. button.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(0, 0, 0)
  74. buttonStates[name] = isEnabled
  75. saveButtonStates()
  76. onClick(isEnabled)
  77. end)
  78.  
  79. return button
  80. end
  81.  
  82. -- Button state saving system
  83. local HttpService = game:GetService("HttpService")
  84. local buttonStates = {}
  85.  
  86. -- Function to save button states
  87. local function saveButtonStates()
  88. local success, err = pcall(function()
  89. local saveData = HttpService:JSONEncode(buttonStates)
  90. writefile("buttonStates.json", saveData)
  91. end)
  92. end
  93.  
  94. -- Function to load button states
  95. local function loadButtonStates()
  96. if isfile("buttonStates.json") then
  97. local success, data = pcall(function()
  98. return HttpService:JSONDecode(readfile("buttonStates.json"))
  99. end)
  100. if success then
  101. buttonStates = data
  102. end
  103. end
  104. end
  105.  
  106. local isEnabled = buttonStates[name] or false
  107. button.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(0, 0, 0)
  108.  
  109. -- If button was previously enabled, activate it
  110. if isEnabled then
  111. onClick(true)
  112. end
  113.  
  114. button.MouseButton1Click:Connect(function()
  115. isEnabled = not isEnabled
  116. button.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(0, 0, 0)
  117. buttonStates[name] = isEnabled
  118. saveButtonStates()
  119. onClick(isEnabled)
  120. end)
  121.  
  122. return button
  123. end
  124.  
  125. -- Load saved states when script starts
  126. loadButtonStates()
  127.  
  128. -- Load saved states when script starts
  129. loadButtonStates()
  130. -- Kill Aura Function
  131. local killAuraActive = false
  132. local killAuraLoop = nil
  133. local function toggleKillAura(isEnabled)
  134. killAuraActive = isEnabled
  135. if isEnabled then
  136. if not killAuraLoop then
  137. killAuraLoop = spawn(function()
  138. while killAuraActive do
  139. local args = {
  140. [1] = {
  141. [1] = {
  142. ["animationLength"] = 0,
  143. ["sentAt"] = tick()
  144. },
  145. [2] = "G"
  146. }
  147. }
  148. game:GetService("ReplicatedStorage").dataRemoteEvent:FireServer(unpack(args))
  149. wait(0)
  150. end
  151. end)
  152. end
  153. else
  154. killAuraActive = false
  155. killAuraLoop = nil
  156. end
  157. end
  158.  
  159. -- Function to override other GUIs
  160. local function overrideOtherGUIs()
  161. local function processGui(gui)
  162. if gui.Name ~= "PersistentGUI" then -- Don't affect our GUI
  163. gui.ZIndex = 1 -- Set lower ZIndex
  164.  
  165. -- Process all descendants
  166. for _, desc in ipairs(gui:GetDescendants()) do
  167. if desc:IsA("GuiObject") then
  168. desc.ZIndex = 1
  169. end
  170. end
  171.  
  172. -- Watch for new elements
  173. gui.DescendantAdded:Connect(function(desc)
  174. if desc:IsA("GuiObject") then
  175. desc.ZIndex = 1
  176. end
  177. end)
  178. end
  179. end
  180.  
  181. -- Process existing GUIs
  182. for _, gui in ipairs(game.Players.LocalPlayer:WaitForChild("PlayerGui"):GetChildren()) do
  183. processGui(gui)
  184. end
  185.  
  186. -- Watch for new GUIs
  187. game.Players.LocalPlayer.PlayerGui.ChildAdded:Connect(processGui)
  188. end
  189.  
  190. -- Call the override function
  191. overrideOtherGUIs()
  192.  
  193. - tp
  194. local function toggleTP(isEnabled)
  195. tpActive = isEnabled
  196. if isEnabled then
  197. if not tpLoop then
  198. tpLoop = spawn(function()
  199. while tpActive do
  200. local Players = game:GetService("Players")
  201. local LocalPlayer = Players.LocalPlayer
  202. local Character = LocalPlayer.Character
  203.  
  204. local function findNearestNPC()
  205. local nearestNPC = nil
  206. local nearestDistance = math.huge
  207.  
  208. if not Character or not Character:FindFirstChild("HumanoidRootPart") then return end
  209.  
  210. for _, folder in ipairs(workspace:GetChildren()) do
  211. if folder:IsA("Folder") then
  212. for _, child in ipairs(folder:GetChildren()) do
  213. if child:FindFirstChild("enemyFolder") then
  214. for _, npc in ipairs(child.enemyFolder:GetChildren()) do
  215. if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
  216. local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
  217. if distance < nearestDistance then
  218. nearestDistance = distance
  219. nearestNPC = npc
  220. end
  221. end
  222. end
  223. end
  224. end
  225. end
  226. end
  227. return nearestNPC
  228. end
  229.  
  230. if Character and Character:FindFirstChild("HumanoidRootPart") then
  231. local targetNPC = findNearestNPC()
  232.  
  233. if targetNPC and targetNPC:FindFirstChild("HumanoidRootPart") then
  234. local npcPosition = targetNPC.HumanoidRootPart.Position
  235. local offset = Vector3.new(0, 9, 0) -- Changed to 12 studs height
  236. local targetPosition = npcPosition + offset
  237.  
  238. -- Create CFrame that positions above target and looks at them
  239. local lookAt = CFrame.new(targetPosition, npcPosition)
  240. Character.HumanoidRootPart.CFrame = lookAt
  241. end
  242. end
  243.  
  244. wait(0.1) -- Small wait to prevent excessive updates
  245. end
  246. end)
  247. end
  248. else
  249. tpActive = false
  250. tpLoop = nil
  251. end
  252. end
  253. -- Auto-Ability Function
  254. local abilityActive = false
  255. local abilityLoop = nil
  256. local function toggleAbility(isEnabled)
  257. abilityActive = isEnabled
  258. if isEnabled then
  259. if not abilityLoop then
  260. abilityLoop = spawn(function()
  261. local VirtualInputManager = game:GetService("VirtualInputManager")
  262. local lastKeyPress = 0
  263. local keyPressCooldown = 0.5
  264.  
  265. while abilityActive do
  266. local Character = player.Character
  267. if Character and Character:FindFirstChild("HumanoidRootPart") then
  268. local function isNearMobs(range)
  269. for _, folder in ipairs(workspace:GetChildren()) do
  270. if folder:IsA("Folder") then
  271. for _, child in ipairs(folder:GetChildren()) do
  272. if child:FindFirstChild("enemyFolder") then
  273. for _, npc in ipairs(child.enemyFolder:GetChildren()) do
  274. if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
  275. local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
  276. if distance <= range then
  277. return true
  278. end
  279. end
  280. end
  281. end
  282. end
  283. end
  284. end
  285. return false
  286. end
  287.  
  288. if isNearMobs(20) and tick() - lastKeyPress >= keyPressCooldown then
  289. VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.E, false, nil)
  290. task.wait()
  291. VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.E, false, nil)
  292.  
  293. VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.Q, false, nil)
  294. task.wait()
  295. VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.Q, false, nil)
  296.  
  297. lastKeyPress = tick()
  298. end
  299. end
  300. wait(0.1)
  301. end
  302. end)
  303. end
  304. else
  305. abilityActive = false
  306. abilityLoop = nil
  307. end
  308. end
  309.  
  310. -- Coin-TP Function
  311. local coinTPActive = false
  312. local coinTPLoop = nil
  313. local function toggleCoinTP(isEnabled)
  314. coinTPActive = isEnabled
  315. if isEnabled then
  316. if not coinTPLoop then
  317. coinTPLoop = spawn(function()
  318. while coinTPActive do
  319. local function waitForCoin()
  320. while not workspace:FindFirstChild("Coin") or not workspace.Coin:FindFirstChild("Coin") do
  321. wait(2)
  322. if not coinTPActive then return nil end
  323. end
  324. return workspace.Coin.Coin
  325. end
  326.  
  327. local coin = waitForCoin()
  328. if coin and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  329. local offset = Vector3.new(0, 8, 0)
  330. for i = 1, 20 do
  331. if not coinTPActive then break end
  332. player.Character.HumanoidRootPart.CFrame = CFrame.new(coin.Position + offset)
  333. wait(0.01)
  334. end
  335. end
  336. wait(0.1)
  337. end
  338. end)
  339. end
  340. else
  341. coinTPActive = false
  342. coinTPLoop = nil
  343. end
  344. end
  345.  
  346. -- Auto-retry function
  347. local function toggleAutoRetry(isEnabled)
  348. if isEnabled then
  349. -- Create a connection to watch for end of dungeon
  350. local function checkForEndScreen()
  351. local frame = game.Players.LocalPlayer.PlayerGui:FindFirstChild("endFrame")
  352. if frame and frame.Visible then
  353. wait(1) -- Wait a brief moment
  354. local args = {
  355. [1] = {
  356. [1] = {
  357. ["\3"] = "vote",
  358. ["vote"] = true
  359. },
  360. [2] = "."
  361. }
  362. }
  363. game:GetService("ReplicatedStorage").dataRemoteEvent:FireServer(unpack(args))
  364. end
  365. end
  366.  
  367. -- Connect to PlayerGui changes
  368. game.Players.LocalPlayer.PlayerGui.ChildAdded:Connect(function(child)
  369. if child.Name == "endFrame" then
  370. checkForEndScreen()
  371. end
  372. end)
  373.  
  374. -- Check existing GUI in case we're already at end screen
  375. checkForEndScreen()
  376. end
  377. end
  378.  
  379. -- Auto Start Function
  380. local function autoStart()
  381. game:GetService("ReplicatedStorage").remotes.changeStartValue:FireServer()
  382. end
  383.  
  384. -- Connect to PlayerAdded event
  385. game.Players.LocalPlayer.CharacterAdded:Connect(function()
  386. wait(1) -- Wait a short moment to ensure everything is loaded
  387. autoStart()
  388. end)
  389.  
  390. -- Create all buttons
  391. createToggleButton(1, "Kill Aura", toggleKillAura)
  392. createToggleButton(2, "TP", toggleTP)
  393. createToggleButton(3, "Auto-Ability", toggleAbility)
  394. createToggleButton(4, "Coin-TP", toggleCoinTP)
  395. createToggleButton(5, "Auto-Retry", toggleAutoRetry) -- Add this line
  396.  
  397. -- Add padding at the top of the frame
  398. local UIPadding = Instance.new("UIPadding")
  399. UIPadding.Parent = MainFrame
  400. UIPadding.PaddingTop = UDim.new(0, 20)
  401.  
  402. -- Rounded corners
  403. local cornerFrame = Instance.new("UICorner")
  404. cornerFrame.CornerRadius = UDim.new(0.05, 0)
  405. cornerFrame.Parent = MainFrame
  406.  
  407. local cornerButton = Instance.new("UICorner")
  408. cornerButton.CornerRadius = UDim.new(0.3, 0)
  409. cornerButton.Parent = CloseButton
  410.  
  411. -- Store references
  412. gui = ScreenGui
  413. mainFrame = MainFrame
  414. closeButton = CloseButton
  415.  
  416. -- Toggle function
  417. local function toggleGui()
  418. MainFrame.Visible = not MainFrame.Visible
  419. CloseButton.Text = MainFrame.Visible and "Close" or "Open"
  420. end
  421.  
  422. -- Make elements draggable independently
  423. local function makeDraggable(gui)
  424. local dragging = false
  425. local dragStart = nil
  426. local startPos = nil
  427. local dragInput = nil
  428.  
  429. gui.InputBegan:Connect(function(input)
  430. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  431. dragging = true
  432. dragStart = input.Position
  433. startPos = gui.Position
  434.  
  435. input.Changed:Connect(function()
  436. if input.UserInputState == Enum.UserInputState.End then
  437. dragging = false
  438. end
  439. end)
  440. end
  441. end)
  442.  
  443. gui.InputChanged:Connect(function(input)
  444. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  445. dragInput = input
  446. end
  447. end)
  448.  
  449. game:GetService("UserInputService").InputChanged:Connect(function(input)
  450. if input == dragInput and dragging then
  451. local delta = input.Position - dragStart
  452. gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  453. end
  454. end)
  455. end
  456.  
  457. makeDraggable(CloseButton)
  458. makeDraggable(MainFrame)
  459. CloseButton.MouseButton1Click:Connect(toggleGui)
  460. end
  461.  
  462. -- Button state saving system
  463. local HttpService = game:GetService("HttpService")
  464. local buttonStates = {}
  465.  
  466. -- Function to save button states
  467. local function saveButtonStates()
  468. local success, err = pcall(function()
  469. local saveData = HttpService:JSONEncode(buttonStates)
  470. writefile("buttonStates.json", saveData)
  471. end)
  472. end
  473.  
  474. -- Function to load button states
  475. local function loadButtonStates()
  476. if isfile("buttonStates.json") then
  477. local success, data = pcall(function()
  478. return HttpService:JSONDecode(readfile("buttonStates.json"))
  479. end)
  480. if success then
  481. buttonStates = data
  482. end
  483. end
  484. end
  485.  
  486. -- Modified createToggleButton function (replace the existing one)
  487. local function createToggleButton(number, name, onClick)
  488. local button = Instance.new("TextButton")
  489. button.Size = UDim2.new(0.7, 0, 0, 30)
  490. button.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  491. button.Text = name
  492. button.TextColor3 = Color3.fromRGB(255, 255, 255)
  493. button.Font = Enum.Font.SourceSansBold
  494. button.TextSize = 14
  495. button.LayoutOrder = number
  496. button.Parent = MainFrame
  497. button.ZIndex = 2
  498.  
  499. local corner = Instance.new("UICorner")
  500. corner.CornerRadius = UDim.new(0.3, 0)
  501. corner.Parent = button
  502.  
  503. -- Load saved state
  504. local isEnabled = buttonStates[name] or false
  505. button.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(0, 0, 0)
  506.  
  507. -- If button was previously enabled, activate it
  508. if isEnabled then
  509. onClick(true)
  510. end
  511.  
  512. button.MouseButton1Click:Connect(function()
  513. isEnabled = not isEnabled
  514. button.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 0, 255) or Color3.fromRGB(0, 0, 0)
  515. buttonStates[name] = isEnabled
  516. saveButtonStates()
  517. onClick(isEnabled)
  518. end)
  519.  
  520. return button
  521. end
  522.  
  523. -- Load saved states when script starts
  524. loadButtonStates()
  525.  
  526. -- Create initial GUI
  527. createGui()
  528.  
  529. -- Handle character respawning
  530. player.CharacterAdded:Connect(function()
  531. if not gui or not gui.Parent then
  532. createGui()
  533. end
  534. end)
  535.  
  536. -- Handle player removal
  537. player.AncestryChanged:Connect(function(_, parent)
  538. if not parent then
  539. gui:Destroy()
  540. end
  541. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement