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 4 years ago
Edited 4 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)

if game.workspace.Part.Touched then

or

function 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 4 years ago
Edited 4 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:

local Part = game.Workspace.Part 

Part.Touched:Connect(function()
    AwardBadge() -- This would be where your badge awarding function is called
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.

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

Hello, here's the script you wanted:

THIS IS A SCRIPT!

  local Part = game.Workspace.Part
  local BadgeService = game:GetService("BadgeService")

    function awardBadge(player, badgeId)

        if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then

            BadgeService:AwardBadge(player.UserId, badgeId)

        end
    end

    Part.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            awardBadge(game.Players[hit.Parent.Name].UserId,000000) -- insted of the zero's put ur badge id in
        end
    end)

use it if you want to

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

Answer this question