Badge award sound

Hey guys, I need a little bit of help.

I’m in a hurry because the game I’m working on has a deadline but I don’t know how to do something.
Is there anyway to make a badge play this sound ID when you get awarded it? (1112076929)
I’m very confused on how and there’s no Devfourms or anything about/how to do it.

If you could help then that’d be amazing, again I’m hurrying because dead-line is soon.

Thanks!

2 Likes

This is really simple. All you need to do is add a line in your code which will play a sound ID, like this:

  1. Add a sound in SoundService
  2. Right below the line of code which gives you the badge, or after a certain number of seconds, add the line of code which will play the sound you desire.
    This is how the line of code should look like. “mysound” is where your sound name goes:
local soundService = game:GetService("SoundService")

-- Your current badge-awarder code goes here, or how long until the sound plays.

soundService.mysound:Play() -- Put this **AFTER** the bage giver script.

sound:Play()
AwardBadge()
realy simple

Alright, I’ll test it with the Hoop badge, thanks!

Some reason it didnt work, no sound played but the badge got awarded?

Did you add a Sound in SoundService, added a Sound ID and named it something? (in this example, name it “mysound” you can always change it later.)

Heres the code, image

local soundService = game:GetService(“SoundService”)

print("Badge Awarder Loaded. BadgeID: " … script.Parent.BadgeID.Value)

– ROBLOX scripter hackers, see what you can do with this:
– 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”)
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.

You have to play the sound inside the function.

Also, I recommend putting your script in code blocks for formatting and better readability.

Yep, did exactly what you told me to but it for some odd reason didn’t work.

Try debugging or checking the output log, I don’t really see any errors here however I will check later on today when I have time.

No errors, just checked, it does award me the badge but it doesnt wanna play the sound because theres no log for “Play sound”

Alright, I’ll try this out myself later today and provide an answer if I find the error.

alright, thanks but try to get on asap, time-crunch

i’ve made a function for you

local BadgeService = game:GetService("BadgeService")
 
function AwardBadge(player,badgeId,Soundinstance)
    local success, badgeInfo = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeId)
	end)
	if success then
		-- Confirm that badge can be awarded
		if badgeInfo.IsEnabled then
			-- Award badge
			local awarded, errorMessage = pcall(function()
				--play the sound
				Soundinstance:Play()
				BadgeService:AwardBadge(player.UserId, badgeId)
			end)
			if not awarded then
				warn("Error while awarding badge:", errorMessage)
			end
		end
	else
		warn("Error while fetching badge info!")
	end
end

a call

AwardBadge(game.Players.Qin2007,Id,MySound)

try again now?

Alright ill test it, so all I do I replace the other Badge Award script with this?

badge service is wrong I think, I’m not good with lines lmao

its realy the default badge script but i play the sound before the function of awarding the badge

Did you check if the sound is enabled?

I have no idea what to do, there is no touch part script so I’m very confused

Yep it’s enabled, 10000000000000%