Advertisement
iiJosephCats205

Bage

May 28th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. local BadgeService = game:GetService("BadgeService")
  2. local Players = game:GetService("Players")
  3.  
  4. local badgeID = 1060922754 -- Change this to your badge ID
  5.  
  6. local function onPlayerAdded(player)
  7.  
  8. local hasBadge = false
  9.  
  10. -- Check if the player has the badge
  11. local success, message = pcall(function()
  12. hasBadge = BadgeService:UserHasBadgeAsync(player.UserId, badgeID)
  13. end)
  14.  
  15. -- If there's an error, issue a warning and exit the function
  16. if not success then
  17. warn("Error while checking if player has badge: " .. tostring(message))
  18. return
  19. end
  20.  
  21. if hasBadge == true then
  22. -- Assign this player a property/indicator that they own the badge
  23. --
  24. end
  25. end
  26.  
  27. -- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function
  28. Players.PlayerAdded:Connect(onPlayerAdded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement