Do you know how to make a death badge script?

hello developers i have something to ask you today that may seem like a stupid thing to ask BUT, do any of you know how to make a

“when you die you get a badge script”

it for the sword fight arena in my game.

pls let me know asap.

–teyougin

6 Likes

You’re going to want to create the badge in the first place. That’s pretty simple, just google “How to make a badge roblox”.

Once you do that, you’re going to want a script that detects when the player dies. Use Humanoid.Died event: Humanoid.Died

When the Humanoid dies, detect if they actually died to a player (Use combat tagging of some sort)

If they do die to a player (rather than falling off the map or resetting), then grant them a badge with BadgeService:AwardBadge

LocalScript
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function(tag)
local BadgeService =  game:GetService("BadgeService")
local BadgeId = Id Here
      BadgeService:AwardBadge(game.Players.LocalPlayer.UserId, BadgeId)
end)

1- Use Humanoid.Died() event to detect when the player died.

2- Use pcalls to give the player the badge.

1 Like

Badges can not be awarded from a local script.

Plus, he wants the badge to given when they die.

then just make script with the little bit changed code in starterplayerscripts

Humanoid.Died Be like lol isn’t that died event

No, it’s Died().

https://developer.roblox.com/en-us/api-reference/event/Humanoid/Died

1 Like

it is died:Connect(function() if you can’t read

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			print(player.Name .. " has died!")
		end)
	end)
end)
1 Like

I already knew that :slight_smile:
Died is an event:)

The argue was about “died”.

okay thank you i will try this when i work on my game this weekend. once again ty ty ty ty :slight_smile:

make sure to change it little bit and then transform into script

i would do that but i don’t have roblox studio opened so ye

what do you mean? i suck at scripting btw that’s why i asks for such a stupid thing.

wait little bit i will make script really quickly in roblox studio

okay take all the time you need.

local BadgeService = game:GetService("BadgeService")
local BadgeID = 000000 -- put your badgeID here
local userHasBadge = BadgeService.UserHasBadgeAsync
local awardBadge = BadgeService.AwardBadge


game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		Char.Humanoid.Died:Connect(function()
			local success, result = pcall(userHasBadge, BadgeService, Player.UserId, BadgeID) 
			if success then
				local check2, result2 = pcall(awardBadge, BadgeService, Player.UserId, BadgeID)
				if check2 then
					BadgeService:AwardBadge(Player.UserId,BadgeID)
				end
			end
		end)
	end)
end)
4 Likes

there is easier version which works aswell

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
plr.Character.Humanoid.Died:Connect(function(tag)
	print("Died")
	local BadgeService =  game:GetService("BadgeService")
	local BadgeId = 1
	BadgeService:AwardBadge(plr.UserId, BadgeId)

		end)
	end)
end)
2 Likes

make script and then place it in workspace
here is code for script

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
plr.Character.Humanoid.Died:Connect(function(tag)
	print("Died")
	local BadgeService =  game:GetService("BadgeService")
	local BadgeId = 1
	BadgeService:AwardBadge(plr.UserId, BadgeId)

		end)
	end)
end)
9 Likes