HI everyone right now I am lost at a part of my game where I am trying to award a badge to the players after winning.
If anyone can help me award the badge to the players that would be really helpful my badge ID is
–2125740328–
Thanks everyone.
game:GetService(“BadgeService”):AwardBadge(player.UserId,2125740328)
Well, tell us the type of game, obby, time trial game?
Im designing a Horror game and when you get to the end you are awarded with a badge
Thats the badge Id, not a user id
How do you finish? By touching a part? Or by time
Also, next time PLEASE read the devforum structure it begs you to use. That way you won’t have to make a post about issues as simple as these, seeing as you will look for solutions online first. If you already looked for any solutions, that’s my bad.
By touching a part it triggers to the server tho
I am still finding out how to make the badge trigger if i knew already then why would i make this post lol
When searching for something, don’t be too specific. Sorry if i’m annoying here, but Roblox has a few tutorials that pop up when searching this sort of stuff.
thanks ill look into that right now
I think thats like a part thing
So if you want to give a player the badge, just put this in the part that they need to touch
local BadgeService = game:GetService(“BadgeService”)
local id = YOUR BADGE ID
local badgegive = game.Workspace.YOUR PART
badgegive.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not BadgeService:UserHasBadgeAsync(plr.UserId, id) then
BadgeService:AwardBage(plr.UserId, id)
end
end
end)
Will this script only give the badge to the player who touches the part?
Yes, I am pretty sure, I have checked it
Tell me if it has errors
Alright let me do a test and Ill get back to you.
It may print out a bunch of errors if a humanoid that isn’t a player touches the part, though.
But other than that, the script is good.
Ah, right, thanks for pointing that out
So if NPCs touch the part, it prints errors
Good to know
alright other than that do u guys think the script is clean?
Yes, events print out errors but never stop triggering. It’s fine, though you should change the if line to
if plr and not BadgeService:UserHasBadgeAsync(plr.UserId, id) then