Advertisement
CatDev125

Roblox Stream Sniper Reborn (2024)

Mar 27th, 2024 (edited)
10,166
2
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.78 KB | Gaming | 2 0
  1. local Players = game:GetService("Players")
  2. local TeleportService = game:GetService("TeleportService")
  3. local HttpService = game:GetService("HttpService")
  4. local GuiService = game:GetService("GuiService")
  5. local CoreGui = game:GetService("CoreGui")
  6. local StarterGui = game:GetService("StarterGui")
  7.  
  8. -- Create UI
  9. local screenGui = Instance.new("ScreenGui")
  10. local frame = Instance.new("Frame")
  11. local userIdTextbox = Instance.new("TextBox")
  12. local placeIdTextbox = Instance.new("TextBox")
  13. local playerCountTextbox = Instance.new("TextBox")
  14. local startButton = Instance.new("TextButton")
  15. local closeButton = Instance.new("TextButton")
  16. local label = Instance.new("TextLabel")
  17.  
  18. -- Configure UI elements
  19. frame.BackgroundColor3 = Color3.new(0.15, 0.15, 0.15)
  20. closeButton.BackgroundColor3 = Color3.new(0.25, 0.25, 0.25)
  21. label.BackgroundColor3 = Color3.new(0.25, 0.25, 0.25)
  22. startButton.BackgroundColor3 = Color3.new(0.25, 0.25, 0.25)
  23. userIdTextbox.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
  24. placeIdTextbox.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
  25. playerCountTextbox.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
  26.  
  27. closeButton.TextColor3 = Color3.new(1, 1, 1)
  28. label.TextColor3 = Color3.new(1, 1, 1)
  29. startButton.TextColor3 = Color3.new(1, 1, 1)
  30. userIdTextbox.TextColor3 = Color3.new(1, 1, 1)
  31. placeIdTextbox.TextColor3 = Color3.new(1, 1, 1)
  32. playerCountTextbox.TextColor3 = Color3.new(1, 1, 1)
  33.  
  34. closeButton.BorderSizePixel = 0
  35. label.BorderSizePixel = 0
  36. startButton.BorderSizePixel = 0
  37. userIdTextbox.BorderSizePixel = 0
  38. placeIdTextbox.BorderSizePixel = 0
  39. playerCountTextbox.BorderSizePixel = 0
  40.  
  41. -- Set default values and parent elements
  42. frame.Size = UDim2.new(0, 300, 0, 290)
  43. frame.Position = UDim2.new(0.5, -150, 0.5, -145)
  44. frame.Parent = screenGui
  45.  
  46. closeButton.Text = "Close"
  47. closeButton.Size = UDim2.new(0, 75, 0, 40)
  48. closeButton.Position = UDim2.new(1, -75, 0, 0)
  49. closeButton.Parent = frame
  50.  
  51. label.Text = "Stream Sniper Reborn"
  52. label.Size = UDim2.new(0, 225, 0, 40)
  53. label.Position = UDim2.new(0, 0, 0, 0)
  54. label.Parent = frame
  55.  
  56. userIdTextbox.Text = ""
  57. userIdTextbox.Size = UDim2.new(0, 280, 0, 50)
  58. userIdTextbox.Position = UDim2.new(0, 10, 0, 50)
  59. userIdTextbox.PlaceholderText = "User Id"
  60. userIdTextbox.Parent = frame
  61.  
  62. placeIdTextbox.Text = tostring(game.PlaceId) -- Default PlaceId
  63. placeIdTextbox.Size = UDim2.new(0, 280, 0, 50)
  64. placeIdTextbox.Position = UDim2.new(0, 10, 0, 110)
  65. placeIdTextbox.PlaceholderText = "Place Id"
  66. placeIdTextbox.Parent = frame
  67.  
  68. playerCountTextbox.Text = "1"
  69. playerCountTextbox.Size = UDim2.new(0, 280, 0, 50)
  70. playerCountTextbox.Position = UDim2.new(0, 10, 0, 170)
  71. playerCountTextbox.PlaceholderText = "Minimum Player Count"
  72. playerCountTextbox.Parent = frame
  73.  
  74. startButton.Text = "Start"
  75. startButton.Size = UDim2.new(0, 280, 0, 50)
  76. startButton.Position = UDim2.new(0, 10, 0, 230)
  77. startButton.Parent = frame
  78.  
  79. screenGui.Parent = CoreGui
  80.  
  81. -- Functions
  82.  
  83. local function status(text)
  84.     startButton.Text = text
  85. end
  86.  
  87. local function notify(title, text)
  88.     StarterGui:SetCore("SendNotification", {
  89.         Title = title,
  90.         Text = text,
  91.         Duration = 3
  92.     })
  93. end
  94.  
  95. -- Http Requests
  96. local reqf
  97. if syn and syn.request then
  98.    reqf = syn.request
  99. elseif request then
  100.    reqf = request
  101. elseif http and http.request then
  102.    reqf = http.request
  103. elseif http_request then
  104.    reqf = http_request
  105. else
  106.     notify("Error", "Your executor does not support http requests")
  107. end
  108.  
  109. local function fetchJson(url)
  110.     return HttpService:JSONDecode(reqf({Url = url}).Body)
  111. end
  112.  
  113. -- Function to get user avatar by UserId
  114. local function getUserAvatarByUserId(userId)
  115.     local url = "https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds="..userId.."&size=48x48&format=Png&isCircular=false"
  116.     local response = reqf({Url = url}).Body
  117.     return HttpService:JSONDecode(response).data[1].imageUrl
  118. end
  119.  
  120. -- Function to get user avatars by PlayerTokens
  121. local function getUserAvatarsByTokens(playerTokens)
  122.     local url = "https://thumbnails.roblox.com/v1/batch"
  123.     local data = {}
  124.     for _, token in ipairs(playerTokens) do
  125.         table.insert(data, {
  126.             token = token,
  127.             type = "AvatarHeadShot",
  128.             size = "48x48",
  129.             isCircular = false
  130.         })
  131.     end
  132.     data = HttpService:JSONEncode(data)
  133.     local headers = {
  134.         ["Content-Type"] = "application/json"
  135.     }
  136.     local response = reqf({
  137.         Url = url,
  138.         Method = "POST",
  139.         Headers = headers,
  140.         Body = data
  141.     }).Body
  142.     local imageUrls = {}
  143.     for _, item in ipairs(HttpService:JSONDecode(response).data) do
  144.         table.insert(imageUrls, item.imageUrl)
  145.     end
  146.     return imageUrls
  147. end
  148.  
  149. local running = false
  150. local debounce = false
  151. local kill = false
  152.  
  153. -- Main function
  154. local function main()
  155.     if kill then return end
  156.     if running then
  157.         if debounce then
  158.             notify("Cancelled", "Cancelled")
  159.             kill = true
  160.         else
  161.             debounce = true
  162.             notify("Confirm action", "Click again to cancel")
  163.             wait(3)
  164.             if running then
  165.                 debounce = false
  166.             end
  167.         end
  168.         return
  169.     else
  170.         running = true
  171.     end
  172.  
  173.     local userId = tonumber(userIdTextbox.Text)
  174.     local placeId = tonumber(placeIdTextbox.Text)
  175.     local minPlayerCount = tonumber(playerCountTextbox.Text)
  176.    
  177.     if not userId then
  178.         status('Retrieving user id...')
  179.         local userData = HttpService:JSONDecode(reqf({
  180.             Url = "https://users.roblox.com/v1/usernames/users",
  181.             Method = "POST",
  182.             Headers = {
  183.                 ["accept"] = "application/json",
  184.                 ["Content-Type"] = "application/json"
  185.             },
  186.             Body = HttpService:JSONEncode({
  187.                 usernames = { userIdTextbox.Text },
  188.                 excludeBannedUsers = false
  189.             })
  190.         }).Body).data
  191.         if #userData == 0 then
  192.             notify('User does not exist!')
  193.             return
  194.         end
  195.         userId = userData.id
  196.     end
  197.    
  198.     status('Retrieving user info...')
  199.    
  200.     local userInfo = fetchJson("https://users.roblox.com/v1/users/" .. userId)
  201.    
  202.     if userInfo.errors and userInfo.errors[0] then
  203.         notify(userInfo.errors[0].userFacingMessage, userInfo.errors[0].message)
  204.         return
  205.     end
  206.    
  207.     if userInfo.isBanned then
  208.         notify("Error", userInfo.displayName .. " is banned")
  209.     end
  210.    
  211.     notify("Searching for", userInfo.displayName .. " (" .. userInfo.name .. ")")
  212.  
  213.     status("Loading profile picture...")
  214.     local userAvatarUrl = getUserAvatarByUserId(userId)
  215.  
  216.     local cursor = ""
  217.     local found = false
  218.  
  219.     local page = 1
  220.  
  221.     repeat
  222.         if kill then
  223.             kill = false
  224.             running = false
  225.             debounce = false
  226.             return
  227.         end
  228.         -- Get list of servers
  229.         status("Retrieving server list... (page" .. page .. ")")
  230.         local url = "https://games.roblox.com/v1/games/"..placeId.."/servers/Public?sortOrder=Asc&limit=100"
  231.         if cursor then
  232.             url = url .. "&cursor=" .. cursor
  233.         end
  234.         local response = reqf({ Url = url }).Body
  235.         local data = HttpService:JSONDecode(response)
  236.         for i, server in ipairs(data.data) do
  237.             if kill then
  238.                 kill = false
  239.                 running = false
  240.                 debounce = false
  241.                 return
  242.             end
  243.             if server.playing < minPlayerCount then continue end
  244.             status("Scanning servers (page " .. page .. " - " .. i .. "/" .. #data.data .. " - " .. server.playing .. " online)")
  245.             local serverAvatarUrls = getUserAvatarsByTokens(server.playerTokens)
  246.             for _, serverAvatarUrl in ipairs(serverAvatarUrls) do
  247.                 if serverAvatarUrl == userAvatarUrl then
  248.                     status("Player found, teleporting...")
  249.                     wait(0.1)
  250.                     TeleportService:TeleportToPlaceInstance(placeId, server.id, Players.LocalPlayer)
  251.                     found = true
  252.                     wait(3)
  253.                     break
  254.                 end
  255.             end
  256.             if found then break end
  257.         end
  258.  
  259.         cursor = data.nextPageCursor or ""
  260.         page = page + 1
  261.     until found or cursor == ""
  262.  
  263.     if not found then
  264.         notify("Error", "The player was not found on the specified place")
  265.         running = false
  266.     end
  267. end
  268.  
  269. -- Define button click event
  270. startButton.MouseButton1Click:Connect(function()
  271.     local Success, Message = pcall(main)
  272.     status('Start')
  273.     if not Success then
  274.         notify("Error", Message)
  275.         screenGui:Destroy()
  276.     end
  277. end)
  278.  
  279. -- Define button click event
  280. closeButton.MouseButton1Click:Connect(function()
  281.     kill = true
  282.     screenGui:Destroy()
  283. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement