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

Is there a way to know who killed a player?

Asked by 4 years ago

So i need this but dont know where to start I need to reward the player for killing another player. I dont know how to?

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

You will need to add this to your tool script : (where the player gets damage)

local tag = Instance.new("StringValue")
tag.Value = KillerName --The name of the player who owns the tool
tag.Name = "creator"
tag.Parent = HitHumanoid --The Humanoid of the player who got damage
game:GetService("Debris"):AddItem(tag,.5)

You will need a script which detects if a player die :

--//Settings\\--
local amt = 1 --//Edit 1 to the number of Points you want to give to the player
local currencyName = "Points" --Change Points to your currency name

--//Script\\--
game.Players.PlayerAdded:connect(function(player)

    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()


            local tag = character.Humanoid:FindFirstChild("creator")


            if tag ~= nil then

                if tag.Value ~= nil then



                    -- Here tag.Value is the player who killed us, so find their leaderstats
                    local statsKiller = tag.Value:FindFirstChild("leaderstats")
                    if statsKiller then

                        -- Award the Points to the player that killed us
                        statsKiller.Points.Value = statsKiller.Points.Value + amt
                    end

                end
            end
        end)
    end)
end)

0
Thanks! Cyrellejheff 11 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

ummm i think you can't...

2
dont answer if you dont know Cyrellejheff 11 — 4y

Answer this question