This tutorial will help you make a badge where it grants you the badge when the developer(s) join the game.
First, make a badge via Creator Hub. (Image is required)
Next, make a script in ServerScriptService and name it “BadgeHandler.” (Optional)
Insert the following script:
local BadgeService = game:GetService('BadgeService')
local listOfDevs = {-- add dev(s) to the list}
function devJoin()
local players = game.Players:GetPlayers()
-- Checks if a dev's username is in the game and list
for _, devcheck in ipairs(listOfDevs) do
local devfind = game.Players:FindFirstChild(devcheck)
if devfind then
-- Awards the badge to everyone
for i, player in pairs(players) do
BadgeService:AwardBadge(player.UserId, -- your badge ID)
end
end
end
end
game.Players.PlayerAdded:Connect(devJoin)
This is the wrong section. Change the topic to #resources:community-tutorials. You can also add a break in the loop after a dev has been found, to avoid overusing badge service. Your code also would’ve errored because you used :GetDescendants instead of :GetPlayers.
Code:
local BadgeService = game:GetService('BadgeService')
local listOfDevs = {-- add dev(s) to the list}
local function devJoin()
local players = game.Players:GetPlayers()
-- Checks if a dev's username is in the game and list
for _, devcheck in ipairs(listOfDevs) do
local devfind = game.Players:FindFirstChild(devcheck)
if devfind then
-- Awards the badge to everyone
for i, player in pairs(players) do
BadgeService:AwardBadge(player.UserId, -- your badge ID)
end
return
end
end
end
game.Players.PlayerAdded:Connect(devJoin)