Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Met the Creator badge script only working for me?

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

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!

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.