Hello there,
So I'm trying to make a script that awards player a badge when a bool value is "true". I know UserID is not a valid member of "Players" thing, but I'm a noob at scripting and I have no idea what to put instead. What should I do now? Here's the script;
while wait() do if game.Workspace.CongratsBadge.Value==true then local badgeID = [MyBadgeID] local badgeService = game:GetService("BadgeService") for _,v in pairs(game.Players:GetPlayers()) do if not badgeService:UserHasBadge(game.Players.UserId, badgeID) then badgeService:AwardBadge(game.Players.UserId, badgeID) end end end
So when using for in pairs, the 'v' is the value you are indexing. So in this case, you could rewrite the code like this to make it easier.
for i, player in pairs(game.Players:GetPlayers()) do -- the player is the actual player, so you could rewrite your code like this: if not badgeService:UserHasBadge(player.UserId, badgeID) then badgeService:AwardBadge(game.Players.UserId, badgeID) end end
I have not tested this nor do I have any experience with badge service, but I think this should work.