Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

UserID is not a valid member of Player?

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

1 answer

✓ Accepted answer

So this is a simple mistake that a lot of new coders make (including me when I was new), and the error is that you have to do player.UserId, not player.UserID.

2 comments

0

Yep! This is your answer right here.

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.