-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchain.lua
40 lines (32 loc) · 1.32 KB
/
chain.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local gameNum = game.Name
game.Players.PlayerAdded:Connect(function(plr)
--do httpservice stuff
local httpService = game:GetService("HttpService")
local games = httpService:GetAsync("https://github.com/Piggy-Gaming/badge-chain/blob/9c1eabff72bcdd397f99b51e53669e43907dd278/games.json")
local gamesDecoded = game:GetService("HttpService"):JSONDecode(games)
local badgeService = game:GetService("BadgeService")
local badges = httpService:GetAsync("https://badgechain.piggygaming.repl.co/getbadges?id=" .. tostring(game.GameId))
local badgesDecoded = httpService:JSONDecode(badges)
local badgeCount = 0
for i = 1, #badgesDecoded do
badgeCount = badgeCount + 1
end
--award badges
local gui = plr.PlayerGui:WaitForChild("MainGUI"):WaitForChild("Background")
gui.gameCount.Text = "Chain: " .. gameNum
for i = 1, #badgesDecoded do
local badgeid = badgesDecoded[i]["id"]
if not badgeService:UserHasBadgeAsync(plr.UserId, badgeid) then
badgeService:AwardBadge(plr.UserId, badgeid)
wait(0.25)
end
gui.badgeCount.Text = "Awarding badge: " .. i .. "/" .. badgeCount
wait()
end
--teleport plr
gui.badgeCount.Text = "Teleporting..."
local nextgame = gamesDecoded[tostring(gameNum + 1)]
print("Teleporting to placeid " .. nextgame
game:GetService("TeleportService"):Teleport(nextgame, plr)
end)
print("script loaded")