Many people use "creator tags" to go about doing this.
What they do is add a snippet of code inside the code that deals damage to a character; this is where a "tag" is created. Often, this tag is an ObjectValue with the player who dealt the damage (or the "killer") set as the Value property of the ObjectValue. For example, here's a snippet of code...
03 | if target.Character ~ = nil then |
04 | if target.Character:FindFirstChild( "Humanoid" ) then |
06 | local tag = Instance.new( "ObjectValue" ) |
09 | tag.Parent = target.Character.Humanoid |
11 | game.Debris:AddItem(tag, 5 ) |
13 | target.Character.Humanoid:TakeDamage( 50 ) |
Using the Died event in Humanoid, we can do something when a player dies. You can either get the first tag that you find in the Humanoid or get all of them and deal with them accordingly (assisted kills?). Here's some example code...
01 | game.Players.PlayerAdded:connect( function (player) |
02 | player.CharacterAdded:connect( function (character) |
03 | local humanoid = character:WaitForChild( "Humanoid" ) |
04 | humanoid.Died:connect( function () |
05 | for key, value in pairs (humanoid:GetChildren()) do |
06 | local killer = value.Value |
Locked by JesseSong
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?