players.PlayerAdded:connect(function(player) -- player added
player.CharacterAdded:connect(function(Character) -- character added
humanoid = Character:WaitForChild("Humanoid") -- set humanoid
humanoid.Died:Connect(function()
if Humanoid:FindFirstChild("creator") ~= nil then
local killer = Humanoid.creator.Value
killer.leaderstats.XP.Value = killer.leaderstats.XP.Value + 10
local plrKilled = RS.Killed:Clone()
plrKilled.Parent = killer.PlayerGui
plrKilled.Frame.TextLabel.Text = "You killed " .. humanoid.Parent.Name .. " (+10 XP)"
wait(2)
plrKilled:Remove()
end
end)
end)
end)
This script does work as expected, however, if you die, you have to kill two people until it pops up. Can someone tell me why?

13 comments
also this script is in ServerScriptService
dont use creator values
what then?
kill detection should be done after adding the damage to the humanoid
Also do not use Remove use Destroy
@kingdom5 i don't understand what you mean by "after adding the damage to the humanoid"
check if the damage done to the humanoid killed the player
then reward the player
@EXpodo1234ALT isnt that what humanoid.Died:Connect(function() is doing?
yes
so then what is my problem?
the problem is this event has no knowledge of the player doing the damage. It is far better to check while doing the damage as this code knows who is doing the damage.
Thank you. I don't really understand how i can add this into an event though?