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

I have no idea how to give badges in game with a giver...Can you help?

Asked by 5 years ago
Edited 5 years ago

****Hello! First of all, im still learning so don't judge me ;-;. Secondly, I already have made a badge, and im wondering how to give it when it's touched. The reason im doing this is because the answers to these questions were 5 years ago. Im sure this is the beginnings I could use maybe(optional)

1if game.workspace.Part.Touched then

or

1function onTouch()

Please help!

P.s please tell me if i use local script or just script

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

For awarding the badges, look at this post on the Roblox Developer Hub

As for the in-game side of things, use this:

1local Part = game.Workspace.Part
2 
3Part.Touched:Connect(function()
4    AwardBadge() -- This would be where your badge awarding function is called
5end)

Don't forget to check if the player already has the badge (which is covered in the post that I have linked), and add a Debounce if you find that you need it.

Ad
Log in to vote
0
Answered by
VitroxVox 884 Moderation Voter
5 years ago
Edited 5 years ago

Hello, here's the script you wanted:

THIS IS A SCRIPT!

01local Part = game.Workspace.Part
02local BadgeService = game:GetService("BadgeService")
03 
04  function awardBadge(player, badgeId)
05 
06      if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
07 
08          BadgeService:AwardBadge(player.UserId, badgeId)
09 
10      end
11  end
12 
13  Part.Touched:Connect(function(hit)
14      if hit.Parent:FindFirstChild("Humanoid") then
15          awardBadge(game.Players[hit.Parent.Name].UserId,000000) -- insted of the zero's put ur badge id in
16      end
17  end)

use it if you want to

0
Use :GetPlayerFromCharacter() instead, since object[name] will be deprecated soon maumaumaumaumaumua 628 — 5y

Answer this question