Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local BadgeService = game:GetService("BadgeService") or game:FindService("BadgeService")
- local Players = game:GetService("Players") or game:FindService("Players")
- local BadgeID1 = 123456789
- local BadgeID2 = 987654321
- local BadgeID3 = 696969696
- Players.PlayerAdded:Connect(function(plr)
- repeat task.wait() until plr:FindFirstChild("leaderstats") ~= nil
- local leaderstats = plr.leaderstats
- local hoursValue = leaderstats["Time Played"]
- hoursValue:GetPropertyChangedSignal("Value"):Connect(function()
- local result
- local a, b = pcall(function()
- result = BadgeService:UserHasBadgeAsync(plr.UserId, BadgeID1)
- end)
- local c, d = pcall(function()
- result = BadgeService:UserHasBadgeAsync(plr.UserId, BadgeID2)
- end)
- local e, f = pcall(function()
- result = BadgeService:UserHasBadgeAsync(plr.UserId, BadgeID3)
- end)
- if not b then
- warn("An error occured while checking player awards, more: "..b)
- return
- end
- if not b then
- warn("An error occured while checking player awards, more: "..d)
- return
- end
- if not b then
- warn("An error occured while checking player awards, more: "..f)
- return
- end
- if hoursValue.Value >= 0.08 and not result then --Change the Value
- local awardBadgeResult
- local s2, e2 = pcall(function()
- awardBadgeResult = BadgeService:AwardBadge(plr.UserId, BadgeID1)
- end)
- if s2 and awardBadgeResult then
- print("Badge was awarded successfully to the player named: "..plr.Name)
- end
- end
- if hoursValue.Value >= 0.08 and not result then --Change the Value
- local awardBadgeResult
- local s2, e2 = pcall(function()
- awardBadgeResult = BadgeService:AwardBadge(plr.UserId, BadgeID2)
- end)
- if s2 and awardBadgeResult then
- print("Badge was awarded successfully to the player named: "..plr.Name)
- end
- end
- if hoursValue.Value >= 0.08 and not result then --Change the Value
- local awardBadgeResult
- local s2, e2 = pcall(function()
- awardBadgeResult = BadgeService:AwardBadge(plr.UserId, BadgeID3)
- end)
- if s2 and awardBadgeResult then
- print("Badge was awarded successfully to the player named: "..plr.Name)
- end
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement