****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)
1 | if game.workspace.Part.Touched then |
or
1 | function onTouch() |
Please help!
P.s please tell me if i use local script or just script
For awarding the badges, look at this post on the Roblox Developer Hub
As for the in-game side of things, use this:
1 | local Part = game.Workspace.Part |
2 |
3 | Part.Touched:Connect( function () |
4 | AwardBadge() -- This would be where your badge awarding function is called |
5 | end ) |
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.
Hello, here's the script you wanted:
THIS IS A SCRIPT!
01 | local Part = game.Workspace.Part |
02 | local 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