So I have this script that awards players after staying in-game for 5 seconds. The script is supposed to award players another badge if they already have the previous badge, but I can't get it to work, any help is appreciated.
local badgeservice = game:GetService('BadgeService') local id = 2124744629 local id2 = 2124814452 function OnPlayerEntered(plr) wait(5) if not badgeservice:UserHasBadgeAsync(plr.UserId, id) then badgeservice:AwardBadge(plr.UserId, id) if badgeservice:UserHasBadgeAsync(plr.IserId, id) then badgeservice:AwardBadge(plr.UserId, id2) end end wait(2) plr:Kick("Congrats, you made it!") end game.Players.PlayerAdded:Connect(OnPlayerEntered)
local badgeservice = game:GetService('BadgeService') local id = 2124744629 local id2 = 2124814452 function OnPlayerEntered(plr) wait(5) if not badgeservice:UserHasBadgeAsync(plr.UserId, id) then badgeservice:AwardBadge(plr.UserId, id) if badgeservice:UserHasBadgeAsync(plr.IserId, id) then badgeservice:AwardBadge(plr.UserId, id2) end end wait(2) plr:Kick("Congrats, you made it!") end game.Players.PlayerAdded:Connect(OnPlayerEntered)
It doesn't work because you might have the badge already, as you see on line 7. If you have the badge already, it will not continue. To fix this, move the second if statement out of the scope.
local badgeservice = game:GetService('BadgeService') local id = 2124744629 local id2 = 2124814452 function OnPlayerEntered(plr) wait(5) if not badgeservice:UserHasBadgeAsync(plr.UserId, id) then badgeservice:AwardBadge(plr.UserId, id) end if badgeservice:UserHasBadgeAsync(plr.IserId, id) then badgeservice:AwardBadge(plr.UserId, id2) end wait(2) plr:Kick("Congrats, you made it!") end game.Players.PlayerAdded:Connect(OnPlayerEntered)