Badge awarding when player joins!

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

I want to make a badge that is awarded to players the FIRST time they join!

  1. What is the issue?
    I tried coding this with a datastore to see if they joined before or if they have played the game before.
    It didn’t really work out…
    image

  2. What solutions have you tried so far?
    I found another “solution” on the dev forum, and it didnt work… And I’m too lazy to watch yt tutorials, sooo… Help?

If you know how to fix it, please respond!

8 Likes

Do

if not badge:UserHasBadgeAsync(plr.UserId, id) then
      badge:AwardBadge(plr,id)
end

instead of

if firsttime == true then
     badge:AwardBadge(plr,id)
end

This is a more efficient way of awarding a new player the welcome badge since the script could try to award the player the badge again if their data gets reset, which can result in an error.

If this still doesn’t work then make a new script with another .PlayerAdded event with the sole purpose of giving the player the welcome badge if they’re new like this:

local badge = game:GetService("BadgeService")
local id = 123456789 --badge id here
game.Players.PlayerAdded:Connect(function(plr)
       if not badge:UserHasBadgeAsync(plr.UserId, id) then
          badge:AwardBadge(plr.UserId,id)
       end
end)
5 Likes

Would this work? I tried it and i might’ve misspelled something cus it aint working
image

That’s because you did bs:AwardBadge(plr,id), not bs:AwardBadge(plr.UserId,id)

1 Like

I do not know…

I join the game and I dont get the badge

I already edited that seconds before you posted this, my bad!

2 Likes

Read my edited reply again.

1 Like

Trying this now…
Thanks for helping

1 Like

Like this???

image

Just noticed that. Sorry char limit

yea like this
Make sure to test it in game not studio to.

Of course, what would be the issue if it wasn’t?

I am testing it ingame…

Going to test it once again,.

it works now thanks…
image

2 Likes

Seriously, you came to the skilled devs on roblox when you could have saved your time and looked on yt

I suggest you look for more sources before posting here

2 Likes

This was faster…
Soo yes… cool