Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My badge giver script doesn't work for some reason that I can't figure out. What's the problem?

Hello there,

I have a small problem with my badge giver script which gives you a badge when you click it. Everything looks fine, but it doesn't give you any badge when you click it. I'm pretty sure the badge ID is correct (my friends also tried it too) and I get no errors in the output. Where did I do wrong?

Here's the script:

local badgeID = [theBadgeID]
local badgeService = game:GetService("BadgeService")
script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
		if playerWhoClicked.Parent:FindFirstChild("Humanoid") then
          local plr = game.Players:GetPlayerFromCharacter(playerWhoClicked.Parent)
		badgeService:AwardBadge(plr.UserId,badgeID)
	end
end)

2 comments

0

Can you make a print statement after the AwardBadge function so it will make sure it runs?

0

I did, but it didn't print anything in the output. The weird thing is, script keeps working after the badge function (the script I have showed in my question) ends without any errors. Nothing seems wrong...

2 answers

have you tryed putting the badge id in

i can only think of 1 way im not sure if it works

badgeservice:AwardBadge(plr.UserId,id)

tell me if this works or not

2 comments

0

I tried, didn't work again. But I solved the problem myself by writing a brand new script.

0

ok

Ok guys so, I made small changes in my script with some help from the tutorials. It works pretty well now, so I fixed my own problem myself. The new script looks like that:

local badgeId = 2124745538
local badgeServ = game:GetService("BadgeService")
local clickDetector = script.Parent.ClickDetector
	clickDetector.MouseClick:Connect(function(plr)
		badgeServ:AwardBadge(plr.UserId, badgeId)
	end)
clickDetector.Parent = script.Parent

This discussion is preserved as it was. New answers, comments, and votes are closed.