Hi! I’m trying to make a script that gives a particular player a badge when “/award username” is typed in chat. My code is working fine, and I’m able to award badges to particular players, but in the console the chat message keeps getting detected and just infinitely spits out that the player has already relieved that badge.
local groupID = 12775006
local MinRankID = 17
local badgeID = 2128422186
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:connect(function(msg)
while true do
wait()
if plr:GetRankInGroup(groupID) >= MinRankID then
if msg:sub(1, 7) == "/award " then
local PlayerToBeAwarded = game.Players:FindFirstChild(msg:sub(8))
if PlayerToBeAwarded then
game:GetService("BadgeService"):AwardBadge(PlayerToBeAwarded.UserId, badgeID)
end
end
end
end
end)
end)
Any help is much appreciated!