Advertisement
UsernameRTX

Votekick Auto-Rejoin

Jul 20th, 2021 (edited)
33,804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | Source Code | 0 0
  1. local PlaceId = 292439477
  2. if game.PlaceId ~= PlaceId then
  3.     return
  4. elseif not game:IsLoaded() then
  5.     game.Loaded:Wait()
  6. end
  7.  
  8. local Players = game:GetService("Players")
  9. local HttpService = game:GetService("HttpService")
  10. local TeleportService = game:GetService("TeleportService")
  11.  
  12. local LocalPlayer = Players.LocalPlayer
  13.  
  14. local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
  15.  
  16. local ChatGame = PlayerGui:WaitForChild("ChatGame")
  17.  
  18. local Votekick = ChatGame:WaitForChild("Votekick")
  19.  
  20. local Title = Votekick:WaitForChild("Title")
  21.  
  22. local Boolean, JobIds = pcall(readfile, "JobIds.json")
  23. if not Boolean then
  24.     writefile("JobIds.json", HttpService:JSONEncode({}))
  25.     JobIds = HttpService:JSONDecode(readfile("JobIds.json"))
  26. else
  27.     JobIds = HttpService:JSONDecode(JobIds)
  28. end
  29.  
  30. local GetRandomJobId = function()
  31.     local JSONDecode = HttpService:JSONDecode(syn.request({
  32.         Url = string.format("https://games.roblox.com/v1/games/%s/servers/Public?sortOrder=Asc&limit=100", tostring(PlaceId)),
  33.         Method = "GET"
  34.     }).Body)
  35.     local Number = 0
  36.     local JobId = JSONDecode.data[math.random(1, table.getn(JSONDecode.data))].id
  37.     if table.find(JobIds, JobId) then
  38.         repeat
  39.             Number = math.random(1, table.getn(JSONDecode.data))
  40.             JobId = JSONDecode.data[Number].id
  41.             task.wait()
  42.         until not table.find(JobIds, JobId) and JSONDecode.data[Number].playing < JSONDecode.data[Number].maxPlayers
  43.         return JobId
  44.     else
  45.         return JobId
  46.     end
  47. end
  48.  
  49. Title:GetPropertyChangedSignal("Text"):Connect(function()
  50.     if string.find(Title.Text, LocalPlayer.Name) then
  51.         table.insert(JobIds, game.JobId)
  52.         writefile("JobIds.json", HttpService:JSONEncode(JobIds))
  53.         TeleportService:TeleportToPlaceInstance(PlaceId, GetRandomJobId())
  54.     end
  55. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement