Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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)
0
Can you make a print statement after the AwardBadge function so it will make sure it runs? Xapelize 2658 — 3y
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... Va1t_Dev 86 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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

0
I tried, didn't work again. But I solved the problem myself by writing a brand new script. Va1t_Dev 86 — 3y
0
ok mintywintytinty 2 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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

Answer this question