As i know, almost every gun when u damage somebody, a creator value gets added to the humanoid that got damaged, that creator value is the player character or plr, i don’t remember.
Following that way you would check if there is a creator value and then award the player that damaged it, the badge.
The Died event doesn’t pass any information. Instead you would want to check the damage being delt to the player before it applies, and check if it would be enough to kill the other player, if so then you could apply the badge
function AwardBadge(player, badgeId)
local success = false
local badgeInfo = nil
local attempts = 0
repeat
attempts += 1
success, badgeInfo = pcall(function()
return game:GetService("BadgeService"):GetBadgeInfoAsync(badgeId)
end)
if not success then wait(5) end
until
success or attempts >= 3
if success then
if badgeInfo.IsEnabled then
local err = nil
success = false
attempts = 0
local HasBadge = false
repeat
attempts += 1
success, err = pcall(function()
HasBadge = game:GetService("BadgeService"):UserHasBadgeAsync(player.UserId, badgeId)
end)
if not success then wait(5) end
until
success or attempts >= 3
if HasBadge then return end
success = false
attempts = 0
err = nil
repeat
attempts += 1
success, err = pcall(function()
game:GetService("BadgeService"):AwardBadge(player.UserId, badgeId)
end)
if not success then wait(5) end
until
success or attempts >= 0
if not success then
warn("Error while awarding badge: ", err)
end
end
else
warn("Error while fetching badge info: "..badgeInfo)
end
end
Humanoid.Died:Connect(function()
local creator = Humanoid:FindFirstChild("creator")
if creator ~= nil then
AwardBadge(creator.Value, 00000)
end
end)
I recommend this script for you, put it in humanoid
Script
BadgeID = 00000 -- Your badge ID here
script.Parent.Died:connect(function()
if script.Parent:FindFirstChild("creator") then --[ you should add a value on the players]
game:GetService("BadgeService"):AwardBadge(script.Parent.creator.Value.userId,BadgeID)
end
end)