Detect when player kill npc with gun kit

Hello! I use the roblox gun kit, and I want to know, how can i detect when player kill NPC ? I made my research, but i dont find where can i find it. So : where do i start, and how ?
Thank you !

When a player gets hit with a bullet, something that’s called a “CreatorTag” gets put into their Character Model

A “CreatorTag” is just simply a “Kill check”, that just tags the player for a couple of seconds before disappearing, a couple of things to keep in mind:

  • A CreatorTag is an ObjectValue, that stores the Killer’s Player Object

  • It is parented to the Target’s Humanoid upon hit

Another script inside ServerScriptService will check for “CreatorTags” when Characters die using the Humanoid.Died Event, and if the Character has a said “CreatorTag”, you can reference the Killer’s stats & add as much as you’d like

function TagHumanoid(Target, Killer)
    local creator = Instance.new("ObjectValue")
    creator.Name = "creator"
    creator.Value = Killer
    creator.Parent = Target.Humanoid
end
--CreatorTag check
game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        Humanoid.Died:Connect(function()
            local creator = Humanoid:FindFirstChild("creator")
            if creator and creator.Value then
                local Player = creator.Value
                local leaderstats = Player:FindFirstChild("leaderstats")

                if leaderstats then
                    leaderstats.Kills.Value += 1
                    leaderstats.Coins.Value += 10
                end
            end
        end)
    end)
end)
2 Likes

thank you a lot man !really :stuck_out_tongue:

1 Like

this does not work for me i put it in starter gui local script and it returns this and error

witch script is this ?