i wanted to do this on a button.
✓ ANSWER ACCEPTED
how do get badge if something gets triggered i really need help because im new?
1 answer
✓ Accepted answer
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
