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

How to award a badge to the player through an item?

Asked by 6 years ago

So I have a script that is placed inside an item in the replicatedstorage.

if (script.Parent.Parent.Parent:FindFirstChild("Humanoid") ~= nil) then
    print "lol"
p = script.Parent.Parent.Parent
    if (p ~= nil) then
        print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
        local b = game:GetService("BadgeService")
        b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
    end
end

When the player has it in their inventory, they should receive a badge, however, it isn't working. Any help?

1 answer

Log in to vote
0
Answered by
Pejorem 164
6 years ago

Just award the badge when they gain the item?!?!?!

and btw you don't need ~= nil when evaluating an expression as such in an if statement.

if script.Parent.Parent.Parent:FindFirstChild("Humanoid") then
    --do stuff
end

this isn't javascript

1
Exactly. Why wait until they get the tool, when you can just award them once they got the tool? hiimgoodpack 2009 — 6y
0
really makes you think. Skepticlemon 24 — 6y
Ad

Answer this question