Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

UserID is not a valid member of Player?

Asked by 2 years ago

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

Log in to vote
1
Answered by
boredlake 256 Moderation Voter
2 years ago

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.

0
Yep! This is your answer right here. ElongatedMongoose 138 — 2y
0
Thanks! boijuztgotrecked4 7 — 2y
Ad

Answer this question