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

Is there a way to find out who killed a player/npc?

Asked by
Benqazx 108
8 years ago

is there a way to find out who killed a player or a NPC?

1 answer

Log in to vote
2
Answered by 8 years ago

Not an in-built ROBLOX, no.

But, you can easily create your own by putting this into your weapon script:

bullet.Touched:connect(function(hit) -- unimportant (Lines 1,2,7,8)
    if hit.Parent.Humanoid then -- important vv
        local tag = Instance.new("StringValue",hit.Parent.Humanoid) -- creates new value
        tag.Name = "creator" -- sets the name
        tag.Value = player.Name -- sets it to the name of the killer
        game.Debris:AddItem(tag,5) -- removes tag after 5 seconds
    end ------------------------- important ^^
end)

Then, when a player dies, it says who killed them (script in the NPC/Character model):

local human = script.Parent:WaitForChild("Humanoid")
human.Died:connect(function()
    local tag = human.Parent:FindFirstChild("creator)
    if tag then
        print(human.Parent.Name.. " was killed by " ..tag.Value) -- prints who died and who caused it
    end
end)

Hope I helped :)

~TDP

Ad

Answer this question