I'm trying to give a badge when the NPC dies but it says that the UserID is not a valid member of the player. How could I fix this? I'd appreciate anyone who can help me.
local Players = game:GetService("Players")
local Bird = script.Parent:WaitForChild("Humanoid")
local BadgeService = game:GetService("BadgeService")
local BadgeID = 0 --I haven't made a badge yet
while wait() do
if Bird.Died then
for i, player in pairs(game.Players:GetPlayers()) do
BadgeService:AwardBadge(player.UserID, BadgeID)
print("Badge has been given.")
end
end
end

2 comments
Yep! This is your answer right here.
Thanks!