Advertisement
Hwng09

Auto Collect Chest By ItzHwng #3319

Jan 26th, 2023 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.06 KB | Source Code | 0 0
  1. function thisCode()
  2.     repeat wait() until game.IsLoaded and (game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()) and (game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait())
  3. if game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("Main", 9e9):FindFirstChild("ChooseTeam") then
  4.     game:GetService("ReplicatedStorage").Remotes.CommF_:InvokeServer("SetTeam", "Marines")
  5. end
  6.     local PlaceID = game.PlaceId
  7.     local AllIDs = {}
  8.     local foundAnything = ""
  9.     local actualHour = os.date("!*t").hour
  10.     local Deleted = false
  11.     local File = pcall(function()
  12.         AllIDs = game:GetService('HttpService'):JSONDecode(readfile("NotSameServers.json"))
  13.     end)
  14.     if not File then
  15.         table.insert(AllIDs, actualHour)
  16.         writefile("NotSameServers.json", game:GetService('HttpService'):JSONEncode(AllIDs))
  17.     end
  18.     function TPReturner()
  19.         local Site;
  20.         if foundAnything == "" then
  21.             Site = game.HttpService:JSONDecode(game:HttpGet('https://games.roblox.com/v1/games/' .. PlaceID .. '/servers/Public?sortOrder=Asc&limit=100'))
  22.         else
  23.             Site = game.HttpService:JSONDecode(game:HttpGet('https://games.roblox.com/v1/games/' .. PlaceID .. '/servers/Public?sortOrder=Asc&limit=100&cursor=' .. foundAnything))
  24.         end
  25.         local ID = ""
  26.         if Site.nextPageCursor and Site.nextPageCursor ~= "null" and Site.nextPageCursor ~= nil then
  27.             foundAnything = Site.nextPageCursor
  28.         end
  29.         local num = 0;
  30.         for i,v in pairs(Site.data) do
  31.             local Possible = true
  32.             ID = tostring(v.id)
  33.             if tonumber(v.maxPlayers) > tonumber(v.playing) then
  34.                 for _,Existing in pairs(AllIDs) do
  35.                     if num ~= 0 then
  36.                         if ID == tostring(Existing) then
  37.                             Possible = false
  38.                         end
  39.                     else
  40.                         if tonumber(actualHour) ~= tonumber(Existing) then
  41.                             local delFile = pcall(function()
  42.                                 delfile("NotSameServers.json")
  43.                                 AllIDs = {}
  44.                                 table.insert(AllIDs, actualHour)
  45.                             end)
  46.                         end
  47.                     end
  48.                     num = num + 1
  49.                 end
  50.                 if Possible == true then
  51.                     table.insert(AllIDs, ID)
  52.                     wait()
  53.                     pcall(function()
  54.                         writefile("NotSameServers.json", game:GetService('HttpService'):JSONEncode(AllIDs))
  55.                         wait()
  56.                         game:GetService("TeleportService"):TeleportToPlaceInstance(PlaceID, ID, game.Players.LocalPlayer)
  57.                     end)
  58.                     wait(4)
  59.                 end
  60.             end
  61.         end
  62.     end
  63.    
  64.     function Teleport()
  65.         while wait() do
  66.             pcall(function()
  67.                 TPReturner()
  68.                 if foundAnything ~= "" then
  69.                     TPReturner()
  70.                 end
  71.             end)
  72.         end
  73.     end
  74.     local veryImportantWaitTime = 0.5
  75.     task.spawn(function()
  76.         while task.wait(veryImportantWaitTime) do
  77.             pcall(function()
  78.                 for i,v in pairs(game.CoreGui:GetDescendants()) do
  79.                     pcall(function()
  80.                         if string.find(v.Name,"ErrorMessage") then
  81.                             if string.find(v.Text,"Security kick") then
  82.                                 veryImportantWaitTime = 1e9
  83.                                 Teleport()
  84.                             end
  85.                         end
  86.                     end)
  87.                 end
  88.             end)
  89.         end
  90.     end)
  91.  
  92.     local AllowRunService = true
  93.     local AllowRunServiceBind = Instance.new("BindableFunction")
  94.     function AllowRunServiceBind.OnInvoke(args)
  95.         if args == "On" then
  96.             AllowRunService = true
  97.         elseif args == "Off" then
  98.             AllowRunService = false
  99.         end
  100.         local CoreGui = game:GetService("StarterGui")
  101.         CoreGui:SetCore("SendNotification", {
  102.             Title = "Auto Collect Chest",
  103.             Text = "Made By ItzHwng #3318",
  104.             Duration = math.huge,
  105.             Callback = AllowRunServiceBind,
  106.             Button1 = "On",
  107.             Button2 = "Off",
  108.         })
  109.     end
  110.  
  111.     local CoreGui = game:GetService("StarterGui")
  112.     CoreGui:SetCore("SendNotification", {
  113.         Title = "Auto Collect Chest",
  114.         Text = "Made By ItzHwng #3318",
  115.         Duration = math.huge,
  116.         Callback = AllowRunServiceBind,
  117.         Button1 = "On",
  118.         Button2 = "Off",
  119.     })
  120.    
  121.     task.spawn(function()
  122.         while true do
  123.             if AllowRunService == true then
  124.                 local hasChar = game.Players.LocalPlayer:FindFirstChild("Character")
  125.                 if not game.Players.LocalPlayer.Character then
  126.        
  127.                 else
  128.                     local hasCrewTag = game.Players.LocalPlayer.Character:FindFirstChild("CrewBBG",true)
  129.                     if hasCrewTag then hasCrewTag:Destroy() end
  130.                     local hasHumanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
  131.                     if hasHumanoid then
  132.                         local Chest = game.Workspace:FindFirstChild("Chest4") or game.Workspace:FindFirstChild("Chest3") or game.Workspace:FindFirstChild("Chest2") or game.Workspace:FindFirstChild("Chest1") or game.Workspace:FindFirstChild("Chest")
  133.                        
  134.                         if Chest then
  135.                             game.Players.LocalPlayer.Character:PivotTo(Chest:GetPivot())
  136.                             firesignal(Chest.Touched,game.Players.LocalPlayer.Character.HumanoidRootPart)
  137.                         else
  138.                             Teleport()
  139.                             break
  140.                         end
  141.                     end
  142.                 end
  143.             end
  144.             task.wait()
  145.         end
  146.     end)
  147.  
  148. end
  149.  
  150. thisCode()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement