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 :/

local badgeID = 454773242
local badgeService = game:GetService("BadgeService")
local creatorUserId = 3902925

local function onPlayerAdded(player)
    wait(1)
    if player.UserId == creatorUserId then
        for _, p in ipairs(game.Players:GetPlayers()) do
        badgeService:AwardBadge(player.userId, badgeID)
        end
    end
end
game.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.

local badgeID = 454773242
local badgeService = game:GetService("BadgeService")
local creatorUserId = 3902925

local function onPlayerAdded(player)
    for _, v in ipairs(game.Players:GetPlayers()) do
        if player.UserId == creatorUserId or v.UserId == creatorUserId then
            badgeService:AwardBadge(v.UserId, badgeID)
        end
    end
end

game.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.

local badgeService = game:GetService("BadgeService")
local badgeID = 454773242
local creatorUserId = 3902925

game.Players.PlayerAdded:connect(function(player)
    if player.UserId == creatorUserId then
        for i,v in pairs(game.Players:GetChildren()) do
            if v.userId > 0 then
                badgeService:AwardBadge(v.userId, badgeID)
            end
        end
    end
end)

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