I want to create a script that gets the player which killed you, but I can’t quite find any documentation or tutorials on this. Any help would be appericated
you need to create a tag system. this is found on roblox created tools like ClassicSword.
this will be a very vague explanation so please bear with me
when a player is hit, the Sword (the attacker is holding) creates a placeholder object with the victim’s name (or the value as the victims’s name) it should be parented to the sword unless you have another way to organize, and it is also created on the server (unless you want exploiters getting the credit even though they have never hit you)
usually these ‘tags’ last a few seconds, use Humanoid.Died to check if the victim has died and if it did, another function is called to reward the attacker (by getting its name through our Tag, parented to the sword)
people use these for combat log systems, if you leave you are penalized, etc.
see more
So the player that gets hit with the item will have a tag attched ot them with the latest attacker?
i made some errors and have edited my message, please check
done
There are a few approaches you can take to implementing a system like this. The most basic of them all include an ObjectValue which gets inserted into each player when they join the game. From then on, design your weapons to write the Player instance of their wielders to that ObjectValue
on attack, but only do this while the attacked player is alive. When the player dies, check the ObjectValue
within that player as it will hold a reference to the last player who attacked them, thus making them the killer. Reset the ObjectValue
to point at nothing when the player respawns.
If you want a more advanced, completely code-based system, you can steal mine. It streamlines the implementation and provides a significant amount of extra information about a player’s death, such as the following:
export type DeathSummary = {
Assists : {Player},
AssistCountAsKiller : Player?,
Killer : Player?,
Time : number,
Cause : string,
Location : Vector3?
}
I only need the player object that last attacked the main player, but thank you!
Of course, that’s why I begun my reply with that solution
Yeah sorry I didn’t quite notice that
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.