Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local BadgeService = game:GetService("BadgeService")
- local Players = game:GetService("Players")
- -- change these
- local OWNER_ID = 174866279 -- can use game.CreatorId for published places
- local BADGE_ID = 1060922754
- local ownerInGame = false
- local function playerAdded(newPlayer)
- if newPlayer.UserId == OWNER_ID then
- -- if new player is the owner, set ownerInGame to true and give everyone the badge
- ownerInGame = true
- for _, player in pairs(Players:GetPlayers()) do
- -- don't award the owner
- if player ~= newPlayer then
- BadgeService:AwardBadge(player.UserId, BADGE_ID)
- end
- end
- elseif ownerInGame then
- -- if the owner is in the game, award the badge
- BadgeService:AwardBadge(newPlayer.UserId, BADGE_ID)
- end
- end
- local function playerRemoving(oldPlayer)
- if oldPlayer.UserId == OWNER_ID then
- -- set ownerInGame to false
- ownerInGame = false
- end
- end
- -- listen for players joining and leaving
- Players.PlayerAdded:Connect(playerAdded)
- Players.PlayerRemoving:Connect(playerRemoving)
- -- fire playerAdded for existing players
- for _, player in pairs(Players:GetPlayers()) do
- playerAdded(player)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement