3

I made a visiting or thanks for joining badge that I made to be given to any new person that joins my game, but it only works sometimes.

I couldn't try anything, the badge gave it to 60 people when 146 people joined! All 146 people were supposed to get it!

This is the badge code:

local badgeID = 2124446943
local badgeService = game:GetService("BadgeService")
function onEntered(player)
wait(1)
if not badgeService:UserHasBadge(player.UserId, badgeID) then
    badgeService:AwardBadge(player.UserId, badgeID)
end
end

game.Players.PlayerAdded:Connect(onEntered)

It was supposed to be given to all the people who visited. Because at some point they were all new!

halfer
  • 18,701
  • 13
  • 79
  • 158
Alex Y
  • 31
  • 1
  • Are there any game logs to see when this is triggered? Maybe there are clues in there as to why this id not trigger for 86 people? – halfer Jan 01 '19 at 19:02

1 Answers1

1

It is an unlikely possibility that only 60 unique people have played your game, but all of them played your game at least twice resulting in 146 visits

Another possibility is that some players disconnect before the wait(1) in your function, so maybe try this:

function onEntered(player)
    repeat wait(0.1) until player ~= nil
        if not badgeService:UserHasBadge(player.UserId, badgeID) then
            badgeService:AwardBadge(player.UserId, badgeID)
        end
    end
end

But I don't think that'll have any effect because the player can't be nil if they've entered... (idk it's a random suggestion don't count on me)

Sorry I wanted to comment instead of typing here but I need 50 reputation to do so

Crabway
  • 64
  • 4