Advertisement
PiggyGaming2020

chain code

Feb 10th, 2023 (edited)
955
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. local gameNum = game:GetService('MarketplaceService'):GetProductInfo(game.PlaceId).Name
  2.  
  3. local httpService = game:GetService("HttpService")
  4. local badgeService = game:GetService("BadgeService")
  5.  
  6. --do httpservice stuff
  7.    
  8. local places = httpService:GetAsync("https://pastebin.com/raw/CUbumpNi")
  9. local placesDecoded = httpService:JSONDecode(places)
  10.  
  11. local badges = httpService:GetAsync("https://badgechain.piggygaming.repl.co/getbadges?id=" .. tostring(game.GameId))
  12. local badgesDecoded = httpService:JSONDecode(badges)
  13.  
  14. local badgeCount = 0
  15. for i = 1, #badgesDecoded do
  16.     badgeCount = badgeCount + 1
  17. end
  18.  
  19. function awardbadges(plr)
  20.     --award badges
  21.     print("awarding badges")
  22.     local gui = plr.PlayerGui:WaitForChild("MainGUI"):WaitForChild("Background")
  23.     gui.gameCount.Text = "Chain: " .. gameNum
  24.  
  25.     for i = 1, #badgesDecoded do
  26.         local badgeid = badgesDecoded[i]
  27.         if not badgeService:UserHasBadgeAsync(plr.UserId, badgeid) then
  28.             badgeService:AwardBadge(plr.UserId, badgeid)
  29.             task.wait(0.25)
  30.         end
  31.         gui.badgeCount.Text = "Awarding badge: " .. i .. "/" .. badgeCount
  32.         task.wait()
  33.  
  34.     end
  35.  
  36.     --teleport plr
  37.     gui.badgeCount.Text = "Teleporting..."
  38.     local nextgame = placesDecoded[tostring(tonumber(gameNum) + 1)]
  39.    
  40.     print("Teleporting to placeid " .. nextgame)
  41.     game:GetService("TeleportService"):Teleport(nextgame, plr)
  42. end
  43. for i,v in ipairs(game.Players:GetPlayers()) do
  44.     awardbadges(v)
  45. end
  46. game.Players.PlayerAdded:Connect(awardbadges)
  47. print("script loaded")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement