As you know, ROBLOX has made badges free.
Here’s a simple badge giver script which awards your first time joiners’
1]
First off, let’s get premade Services provided by ROBLOX.
local PlayerService = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
2]
Next, use the PlayerAdded event. It “activates” every time a player joins.
local PlayerService = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
PlayerService.PlayerAdded:Connect(function(Player)
--[[ CODE WILL BE HERE ]]--
end)
3]
Here comes the Badge-Checking script. FINAL SCRIPT
local PlayerService = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
PlayerService.PlayerAdded:Connect(function(Player)
local BadgeCheckSuccess, BadgeCheckError = pcall(function() --pcall takes care of any errors without 'breaking' your scripts
local PlayerHasBadge = BadgeService:UserHasBadgeAsync(Player.UserId, ReplaceThisWithYourBadgeId)
if not PlayerHasBadge then
BadgeService:AwardBadge(Player.UserId, ReplaceThisWithYourBadgeId)
end
end)
if BadgeCheckError then print(BadgeCheckError) end --This will print any errors to the output.
end)
REMEMBER :
- Paste your Badge ID in ReplaceThisWithYourBadgeId
- To have a good day
Resources used :