From bcd3047ebda4bbfc0fd63fea4034ad324a81ba36 Mon Sep 17 00:00:00 2001 From: pluviolithic Date: Fri, 15 Dec 2023 22:02:15 -0500 Subject: [PATCH] Add welcome badge --- src/server/PlayerManager/Badges.lua | 18 ++++++++++++++++++ src/server/PlayerManager/init.lua | 1 + 2 files changed, 19 insertions(+) create mode 100644 src/server/PlayerManager/Badges.lua diff --git a/src/server/PlayerManager/Badges.lua b/src/server/PlayerManager/Badges.lua new file mode 100644 index 0000000..e94c630 --- /dev/null +++ b/src/server/PlayerManager/Badges.lua @@ -0,0 +1,18 @@ +local Players = game:GetService "Players" +local BadgeService = game:GetService "BadgeService" +local ReplicatedStorage = game:GetService "ReplicatedStorage" + +local badgeIDs = ReplicatedStorage.Config.Badges + +local function awardJoinBadge(player) + if not BadgeService:UserHasBadgeAsync(player.UserId, badgeIDs.Welcome.Value) then + BadgeService:AwardBadge(player.UserId, badgeIDs.Welcome.Value) + end +end + +Players.PlayerAdded:Connect(awardJoinBadge) +for _, player in Players:GetPlayers() do + task.spawn(awardJoinBadge, player) +end + +return 0 diff --git a/src/server/PlayerManager/init.lua b/src/server/PlayerManager/init.lua index 510584d..79766e3 100644 --- a/src/server/PlayerManager/init.lua +++ b/src/server/PlayerManager/init.lua @@ -90,6 +90,7 @@ require(script.GlobalLeaderboards) require(script.SoftShutdown) require(script.Settings) require(script.Tutorial) +require(script.Badges) --require(script.NoobSpawnFix) return 0