I already know how to make a script that gives a player a badge for being in the same server as the owner, and I think I know how to do that for the whole dev team too, but how would I make it so that there is only 1 script used to give the player a badge for meeting a dev? Sorry if it’s a bit confusing just ask if you’re confused.
local badgeService = game.BadgeService
local id = 0 --[[The Badge ID]]--
local Ids = {playerid1, playerid2}
game.Players.PlayerAdded:Connect(function()
if table.find(Ids, Player.UserID) then
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local Player = Players[i]
if not badgeService:UserHasBadgeAsync(Player.UserId, id) then
badgeService:AwardBadge(Player.UserId, id)
end
end
end
end)
local Devs={"DeveloperUsername"}
local BadgeService = game:GetService("BadgeService")
local badgeId=0000 -- change to your badge id
local function _GiveBadge(Player)
-- Fetch badge information
local success, badgeInfo = pcall(function()
return BadgeService:GetBadgeInfoAsync(badgeId)
end)
if success then
-- Confirm that badge can be awarded
if badgeInfo.IsEnabled then
-- Award badge
local success, result = pcall(function()
return BadgeService:AwardBadge(player.UserId, badgeId)
end)
if not success then
-- the AwardBadge function threw an error
warn("Error while awarding badge:", result)
elseif not result then
-- the AwardBadge function did not award a badge
warn("Failed to award badge.")
end
end
else
warn("Error while fetching badge info: " .. badgeInfo)
end
end)
game.Players.PlayerAdded:Connect(function(Player)
if table.find(Devs,Player.Name) then
for i, v in pairs(game.Players:GetPlayers()) do
_GiveBadge(v)
end
else
local Found=nil
for i, v in pairs(Devs) do
if game.Players:FindFirstChild(v) then
Found=true
break
end
end
if Found==true then _GiveBadge(Player) end
end
end)
You use the variable “Player” when it is not defined, and if it was defined you declare it again with Players[i]
Here is my solution:
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local developerIds = {1,2,3476883826}; -- insert user ids here
local badgeId = 0; -- badge id here
Players.PlayerAdded:Connect(function(plr)
if table.find(developerIds,plr.UserId) then
for _,v in ipairs(Players:GetChildren()) do
if v ~= plr and not BadgeService:UserHasBadgeAsync(v.UserId, badgeId) then
BadgeService:AwardBadge(v.UserId,badgeId)
end
end
end
end)
Ah ok then. Maybe just check over the code a bit since in studio it isn’t showing errors.
Edit: I’m not the best at scripting, but the code looks fine to me.
I have just tested, and the script seems to work perfectly fine for me in the latest version of ROBLOX Studio, Could you please show me how you edited it? (as in replaced badgeid variable etc)
By the way, since you tested it in Studio, I must say that the code doesn’t give the badge to the dev.