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

how do get badge if something gets triggered i really need help because im new?

Asked by 1 year ago

i wanted to do this on a button.

1 answer

Log in to vote
1
Answered by 1 year ago

You should use BadgeService:AwardBadge in a Script for this, guessing that you're talking about UI-Button and listen to a RemoteEvent.

First, you'd have to listen for the user clicking on the button:

local Button = script.Parent -- guessing that the script is in the button

Button.MouseButton1Click:Connect(function()
    print("Button was clicked")
end)

Then, you can send a request to the server, using a RemoteEvent that this user should be awarded the badge

local Button = script.Parent -- guessing that the script is in the button
local Event = game.ReplicatedStorage.RequestBadge -- the RemoteEvent you're using

Button.MouseButton1Click:Connect(function()
    Event:FireServer()
end)

To finish this off, you have to listen to the RemoteEvent using a Script, I recommend ServerScriptService:

local Event = game.ReplicatedStorage.RequestBadge -- the RemoteEvent you're using
local BadgeService= game:GetService("BadgeService")
local BadgeId = 000000000 -- the id of your badge

Event.OnServerEvent:Connect(function(player)
    BadgeService:AwardBadge(player.UserId, BadgeId) -- Award the Badge using the player's userid to the user
end)

Note that this script is certainly not perfect, tell me if you have any problems.

Ad

Answer this question