Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Met the Creator badge script only working for me?

Asked by 8 years ago

I'm trying to fix this script but it's not working for anyone else :/

01local badgeID = 454773242
02local badgeService = game:GetService("BadgeService")
03local creatorUserId = 3902925
04 
05local function onPlayerAdded(player)
06    wait(1)
07    if player.UserId == creatorUserId then
08        for _, p in ipairs(game.Players:GetPlayers()) do
09        badgeService:AwardBadge(player.userId, badgeID)
10        end
11    end
12end
13game.Players.PlayerAdded:connect(onPlayerAdded)

2 answers

Log in to vote
0
Answered by
itsJooJoo 195
8 years ago
Edited 8 years ago

You're only awarding the badge to the player, not the others. Also, if somebody else joined, they won't get the badge so I added that too.

01local badgeID = 454773242
02local badgeService = game:GetService("BadgeService")
03local creatorUserId = 3902925
04 
05local function onPlayerAdded(player)
06    for _, v in ipairs(game.Players:GetPlayers()) do
07        if player.UserId == creatorUserId or v.UserId == creatorUserId then
08            badgeService:AwardBadge(v.UserId, badgeID)
09        end
10    end
11end
12 
13game.Players.PlayerAdded:connect(onPlayerAdded)

Basically, whenever someone joins, the game looks through to see if the player is you. If it is, it awards the rest of the players the badge. I'm pretty sure this works, but I didn't test it out.

If this answer helped, please be sure to hit the accept button!

Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

This script should work, and make sure the script is put in to ServerScriptService.

01local badgeService = game:GetService("BadgeService")
02local badgeID = 454773242
03local creatorUserId = 3902925
04 
05game.Players.PlayerAdded:connect(function(player)
06    if player.UserId == creatorUserId then
07        for i,v in pairs(game.Players:GetChildren()) do
08            if v.userId > 0 then
09                badgeService:AwardBadge(v.userId, badgeID)
10            end
11        end
12    end
13end)

The issue with your original script was that the id you sent in for the userId parameter is that the id you are giving is the player that just joined, which would be you, the creator of the game.

Answer this question