Some issue with BadgeService

So I’m having an issue with the GUI I’ve been making (following a tutorial) but I seem to have an issue. Here’s my code.

local BadgeService = game:GetService("BadgeService")
local player = script.Parent.Parent.Parent.Parent.Parent
local UserId = player.UserId

for _,puppy in pairs(workspace.Puppies:GetChildren()) do
	local template = game.ServerStorage.PuppyTemplate:Clone()
	local BadgeId = puppy.BadgeID.Value
	template.Name= puppy.Name
	template.PuppyName.Text = puppy.Name
	template.Parent = script.Parent.Frame
	template.Picture.Image = puppy.Decal.Texture

	if puppy.Difficulty.Value == "Simple" then
		template.Difficulty.BackgroundColor3 = Color3.fromRGB(53,255,134)
		template.LayoutOrder = -3
	elseif puppy.Difficulty.Value == "Moderate" then
		template.Difficulty.BackgroundColor3 = Color3.fromRGB(227, 224, 36)
		template.LayoutOrder = -2
	elseif puppy.Difficulty.Value == "Challenging" then
		template.Difficulty.BackgroundColor3 = Color3.fromRGB(194, 68, 6)
		template.LayoutOrder = -1

	if BadgeService:UserBadgeAsync(UserId, BadgeId) then
		template.BackgroundColor3 = Color3.fromRGB(84, 97, 97)

The issue is on line 25, “if BadgeService:UserBadgeAsync(UserId, BadgeId) then”
This is what it says in my output:

I’ve tried to insert the Badge ID into the actual BadgeID value but even that doesn’t fix the issue.


Before you reply, I’m a pretty beginner scripter and don’t really know what I’m doing, so this mistake might be pretty simple, I’m not sure. Please let me know if you need any more information or pictures!

1 Like

I think you meant to use -

Also, I would suggest using pcalls when working with such services.

1 Like

Okay! That seems to of worked! Thanks for the help! :smiley: I’ll let you know if I have any more issues with it.

1 Like