local soundService = game:GetService(“SoundService”)
print("Badge Awarder Loaded. BadgeID: " … script.Parent.BadgeID.Value)
--– game:GetService(“BadgeService”):UserHasBadge(userid, badgeid)
function OnTouch(part)
if (part.Parent:FindFirstChild(“Humanoid”) ~= nil) then
local p = game.Players:GetPlayerFromCharacter(part.Parent)
if (p ~= nil) then
print("Awarding BadgeID: " …script.Parent.BadgeID.Value … " to UserID: " … p.userId)
local b = game:GetService(“BadgeService”)
game.SoundService.MySound:Play()-- replace MySound with your sound name
b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
end
end
end
script.Parent.Touched:connect(OnTouch)
--– Your current badge-awarder code goes here, or how long until the sound plays.
---soundService.Obtained:Play() – Put this **AFTER** the bage giver script.
Replace SOUNDID with your sound’s ID and replace the BADGE with your badge’s ID.
local SOUNDID = 0;
local BADGE = 0;
script.Parent.Touched:connect(function(t)
if t and t.Parent and t.Parent:FindFirstChild("Humanoid") ~= nil then
local Player = game.Players:FindFirstChild(t.Parent.Name);
local badges = game:GetService("BadgeService");
if badges:UserHasBadge(Player.UserId, script.Parent.BadgeID.Value) then return; end;
local sounds = game:GetService("SoundService");
local NewAudio = Instance.new("Sound", sounds);
NewAudio.SoundId = "rbxassetid://" .. SOUNDID;
NewAudio:Play();
badges:AwardBadge(Player.UserId, script.Parent.BadgeID.Value);
game:GetService("Debris"):AddItem(NewAudio, NewAudio.TimeLength);
end;
end);