#Badge When you touch a Part

1 messages · Page 1 of 1 (latest)

ivory lark
#

Hello, I'd like to make a badge, but the problem is I don't know what to put in the script. Thanks in advance for any answers 🙂

autumn timber
#

Or the roblox docs?

#

Help yourself man. 🙏

ivory lark
#

Oh, I had forgotten about this, okay, thank you

#

The Badge Script is not working, here it is:

#

local BadgeService = game:GetService("BadgeService")
local BadgeId = 472392118680042

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and game.Players:FindFirstChild(hit.Parent.Name) then
local Player = game.Players[hit.Parent.Name]
BadgeService:AwardBadge(Player.UserId, BadgeId)
end
end)

#

It the AwardBadge (line 7) i think because Rbx Studio Report a Error

#

?

dreamy citrus
#

@autumn timber

autumn timber
dreamy citrus
#

oh srry it fixed

#

its

autumn timber
#

Here is the example from the page: local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")

local BADGE_ID = 0

local function awardBadge(player, badgeId)
-- 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 awardSuccess, result = pcall(function()
            return BadgeService:AwardBadge(player.UserId, badgeId)
        end)

        if not awardSuccess 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

local function onPlayerAdded(player)
awardBadge(player, BADGE_ID)
end

Players.PlayerAdded:Connect(onPlayerAdded)

#

I can check ur code tomorrow on my pc

foggy vortexBOT
#

studio** You are now Level 6! **studio

proper wolf
#

roblox studio services sometimes fail

#

besides whats the error anyway