Hello everyone, I wanted to do script so that after the player steps on the Part, he will be given an Alpha tester badge, but this function does not work.
Script:
local badgeservice = game:GetService("BadgeService")
local id = 2127395398
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeservice:AwardBadge(plr.UserId, id)
end
end)
Do you already own the badge? When you create a badge you automatically own it. If you are testing this in studio then you cannot get badges in studio.
As @BirdieI90 said, you aren’t able to award badges via Roblox Studio, add a line of code printing something in the output log if you want to test the function. Here’s an example
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
badgeservice:AwardBadge(plr.UserId, id)
print("Badge Awarded")
end