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)
14 Likes

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

1 Like

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

3 Likes

I do not know…

I join the game and I dont get the badge

1 Like

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

4 Likes

Read my edited reply again.

2 Likes

Trying this now…
Thanks for helping

2 Likes

Like this???

image

3 Likes

Just noticed that. Sorry char limit

1 Like

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

1 Like

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

1 Like

I am testing it ingame…

Going to test it once again,.

1 Like

it works now thanks…
image

3 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

4 Likes

This was faster…
Soo yes… cool

1 Like

where do i supposed to put this script?

1 Like

Put it in server script service

2 Likes

is it a LocalScript or Script?

1 Like

It should be a sever script because its in serverscriptservicr

1 Like