"You met the creator badge!" Not Working

local badgeService = game:GetService("BadgeService")
local creatorBadgeId = 2124480864

local plrs = game:GetService("Players"):GetPlayers()

local makerId = 109470628

game:GetService("Players").PlayerAdded:Connect(function(plr)
	if plr.UserId == makerId then
		wait()
		for i,v in pairs(plrs) do
			if not badgeService:UserHasBadgeAsync(v.UserId, creatorBadgeId) then
				badgeService:AwardBadge(creatorBadgeId)
			end
		end
	end
end)

I don’t know why, but the for loop is not running. :thinking:

7 Likes

You get the list of players at the start of the script, not whenever the player joins.

And to award a badge, you have to pass their userid and badgeid as so: AwardBadge(userid,badgeid)

1 Like
  1. The wait() is useless
  2. You’re getting the player list before the player added meaning it’ll be nothing

According to the Documentation for badgeService:AwardBadge, (seen here BadgeService | Documentation - Roblox Creator Hub)
You need to pass a userid AND badgeid in this method.

badgeService:AwardBadge(v.UserId, creatorBadgeId)

Also, I suggest getting the current list of players when the owner joins the game.

for i,v in pairs(game:GetService("Players"):GetPlayers()) do

Finally, you should check if the owner is already in the game when other players joins so it doesn’t award just when the creator joins.

why not just do it on player joined instead of having that loop

local badgeService = game:GetService("BadgeService")
local creatorBadgeId = 2124480864

local plr = game:GetService("Players"):GetPlayers()

local makerId = 109470628
game.Players.PlayersAdded:Connect(function(plr)
   if plr.UserId == makerId then
		wait()
			if not badgeService:UserHasBadgeAsync(plr.UserId, creatorBadgeId) then
				badgeService:AwardBadge(creatorBadgeId)
			end
		end
	end
end)  

Because they don’t want to award the badge just to themselves. It’s a meet the creator badge.

1 Like

Ok,isnt their just a way to make it where if somebodys character model is close to the character model of the creator and award them the badge

Yes. Use magnitude.

<30characterlimit>

1 Like

Well 30, well if u got a big map just make it like 1000 magnitude just to make sure,so the players wont have to travel to get the badge

How did this topic get to magnitude, and what does distance in a game have to do with being in the game with the creator?

4 Likes

Well it was an easy solution by using magnitude with your player position and the creators position

The 30 character limit is the character limit on the devforum…

If you’re rewarding it basically when they join, why not just use the loop when the creator joins rather then checking magnitude distance of every player on a loop…?

1 Like

Exactly, since the creator is in the game, technically everyone should get the badge. I don’t see the issue here.

2 Likes

Here’s a quick example using your code that incorporates the points above. Note how you not only need to give to all the players when you join, but you need to give to any new players that join whilst you’re still in the game. Take note of the comments and differences.

local badgeService = game:GetService("BadgeService")
local creatorBadgeId = 2124480864

local makerId = 109470628
local makerInGame = false -- This will go to true while the maker is in-game

game:GetService("Players").PlayerAdded:Connect(function(plr)
	if plr.UserId == makerId then
        makerInGame = true -- Maker in game
        local plrs = game:GetService("Players"):GetPlayers() -- Moved inside the event to get the up-to-date list
		for i,v in pairs(plrs) do
			if not badgeService:UserHasBadgeAsync(v.UserId, creatorBadgeId) then
				badgeService:AwardBadge(v.UserId, creatorBadgeId) -- Added userId argument
			end
		end
    elseif makerInGame then -- If the new player isn't the maker, but the maker is in the game
        if not badgeService:UserHasBadgeAsync(plr.UserId, creatorBadgeId) then
			badgeService:AwardBadge(plr.UserId, creatorBadgeId)
		end
	end
end)

game:GetService("Players").PlayerRemoving:Connect(function(plr)
    if plr.UserId == makerId then
        makerInGame = false -- Maker has left the building
    end
end)
12 Likes

That is pretty similar to the example provided on the bottom of the AwardBadge documentation. For future needs, you should search on the web before making a topic about it, especially if exactly what you need is already documented in the Developer Hub.

Ok, so I do know that I need to use the userid I was experimenting with different methods and I must have left it out in this version… :smile: I am going to change some things, brb…

Alright, I used your method because it seems like it would work the best. I think my first version of it worked because I got the badge in testing but I never got the popup saying that I got it… I don’t know which one worked but after some “print” tests the script appeared to work… :smiley: