Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I get the player who killed a humanoid?

Asked by
Nymint 85
10 years ago

Is there a efficient way to get the player who killed a humanoid?

I'm working on a boss fight project, a lot of people will be fighting the boss and hit him nonstop, i'm not sure how to get the player that killed the boss... help, plox?

1 answer

Log in to vote
0
Answered by 10 years ago

Make a modle with values of each players hit damage, and when he dies then fire and compare which is greater

dead = false
winner = {}

function ondied()
if dead == false
then
dead = true
for i,v in pairs(script.Parent:GetChildren())
if v.ClassName ==("NumberValue")
then
if winner[1] < last[1]
then
last[1] = winner
end
last[1] = v
end
if game.Players:FindFirstChild(winner[1].Value) ~= nil
then
--Blah you put your stuff here
end
end


script.Parent.Parent.Parent.Humanoid.Died:connect(ondied)
0
Uhm but that gets the player who did most damage on the final knock out, doesn't it? There could be people with very good weapons and do a lot of damage, i've seen scripts where low damagers can get the kill too. Nymint 85 — 10y
0
then just make 1 value and change it. to last hit. ScriptImpossible 0 — 10y
Ad

Answer this question