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.
This is really simple. All you need to do is add a line in your code which will play a sound ID, like this:
Add a sound in SoundService
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.
– 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.
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