Hello.
How could I go about making a kill log that shows the distance in studs between the player that killed and the player that died?
You can get the position of the player’s HumanoidRootPart and use their Vector3 positions and .magnitude to compare the distances.
Something like
local distance = (player1.HumanoidRootPart.Position - player2.HumanoidRootPart.Position).magnitude
magnitude
make variabled for the 2 players then do
(player1.Position - player2.Position).magnitude
Yes, I know that. It doesn’t help me. I’m having trouble getting the player that died and the player that killed.
Then why did you not say so, this issue has nothing to deal with getting stud kill log.
get the player with health that is 0 or below
then make a variable out of that, and a variable for the player that is not dead
When the attacker hits them, insert an objectvalue into the attacked person. Set that value to the player who attacked them. When the player dies, get the value of the objectvalue, and you can then easily get both players.
I assume you have weapons that can kill players… simply add a method in those weapons that check if the player was killed, which would be the same player the weapon set their health to 0 or below.
After such you can get the person wielding the weapon which would be the person who killed.
Compare their distance’s and use magnitude, and you should have what you need.
The issue is we can’t, it would be unique between weapons.
It’s sword fighting only. So both players use swords.
yes but if you have multiple different swords… the script would/could be different between them.
I assume you damage the players when the sword’s handle touches a player.
Place a check there to see if the player it damaged set the health to or below 0, if so do the stud kill log.
It wouldn’t matter if they’re the same or different swords.
That isn’t very helpful. “do the stud kill log” That’s what I’m asking how to do.
its as simple as checking the player you damaged health if its below or at 0.
simply do
if humanoid.Health <= 0 then
end
In your damage event.
WE cant just give you random code, because it can/would be incoherent with what your game does.
I told you how to get the stud difference, its your turn to figure out how to puzzle that into a stud kill log system based around the systems you have devised.
It’s from an external serverscript. Not from the sword.
Put this in the tool, making it run when they get attacked:
local ObjectValue = Instance.new("ObjectValue", AttackedPerson)
ObjectValue.Value = Attacker
ObjectValue.Name = "Attacker"
game:GetService("Debris"):AddItem(ObjectValue, 5)
In ServerScriptService you can do something like this:
Character.Humanoid.Died:Connect(function()
if Character:FindFirstChild("Attacker") then
-- Get magnitude between the 2 player's humanoidrootpart and then make it so it fires an event to all clients with the parameters having the stud distance, killer, and person that was killed. When received on the client, add the gui that lists this
end
end)
I wrote this on spot and also, I don’t really wanna spoon feed you code, so I’ll let your figure out the rest.
You gave us little insight to your systems underneath, and what you have setup for a kill log system.
We cant just come up with the entire game for you, so give us more info then “how to make a stud kill log”, with the describing text stating how to get the studs from the killed player and the killing player.
Because i gave you how to get the difference between stud distances between two players… its your turn to give more info if this is not what you wanted, or expect dumb answers.