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

How to award a badge when you click a brick?

Award badge when you clicked on a brick doesn't work I tryed to make one but i won't work

help me Thanks :P

wait (2)
print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)



Part789 = script.Part789
p = script.Parent.Players


function onClicked()
	if (script.Part789:FindFirstChild("Humanoid") ~= nil) then
		if (p ~= nil) then
			local BadgeID = 210342277 -- Badge id
			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
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

✓ Accepted answer

The way you defined 'p' was incorrect. Pardon if I re-write your code a bit, but it's just how I'm used to it.

wait (2)
print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)



Part789 = script.Part789



script.Parent.ClickDetector.MouseClick:connect(function(p)
    if (script.Part789:FindFirstChild("Humanoid") ~= nil) then -- I hope this isn't checking for an actual Player's humanoid
        if (p ~= nil) then -- This line isn't really necessary since nothing else can click
            local BadgeID = 210342277 -- Badge id
            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
end)

2 comments

0

Thanks :) i didn't see that

0

No problem.

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