How to make an Assist system?

Hi Developers! :wave:

You know how annoying it is when another player steals your kill and you get nothing? So, I want to have an kill assist to make both players (one who dealt the most damage and who hit the last) get lowered rewards or something.

What I want to know is how you implement this in code? Like I know how you see who killed the player(creator), but I have no idea how you can check who dealt any damage previously.

I will appreciate any help provided! Also if I didn’t clarify some information, let me know!

Keep a list of recent hits for each player. When a player is hit, put the player who hit him in the list. When player dies, most recent hit takes the kill and if there is a second or third player who hit him too within a certain timeframe, give them the assist.

Is this what you’re looking for?

1 Like

After a weapon applies damage to a humanoid you should then tag that humanoid with a creator tag referencing the player who did the damage, as well as another value that references how much damage was done.
I wrote a function that does this for you:


function tagHumanoid(humanoidThatTookDamage, playerWhoDidDamage, damageDone) 
	if humanoidThatTookDamage ~= nil then 
		local Tags=humanoidThatTookDamage:GetChildren()
		for i=1,#Tags do
			local Tag=Tags[i]
			if Tag:IsA("ObjectValue") then
				if Tag.Value==playerWhoDidDamage then --if creatortag already exists and is equal to playerWhoDidDamage then just add the damage to the existing damage value
					Tag.damage.Value+=damageDone
					return --exit function so it doesnt add a new tag
				end
			end
		end
		
		local creatorTag=Instance.new("ObjectValue") 
		creatorTag.Name="creator" 
		creatorTag.Parent=humanoidThatTookDamage 
		creatorTag.Value=playerWhoDidDamage
		
		local damageTag=Instance.new("NumberValue")
		damageTag.Name="damage"
		damageTag.Parent=creatorTag
		creatorTag.Value=damageDone
		
		
		
		task.wait(5)--removes tag after set amount of time (bad practice)
		--a better practice would be to remove all creatortags when a player is fully healed
		--you can add that inside of a custom health script
		creatorTag:Destroy()
	end 
end 

All you need to do now is write some code that checks for any creator tags when players die.
If more than one creator tag exists you then should compare the damage values inside of each one and then award players accordingly.

2 Likes

@Tnu_IQ yes! That’s what I’m stumbling upon right now.

@cleventa I will check this later in the day!

1 Like