Hello everybody!
I wrote this code in ServerScriptService (SSS):
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
if character.Humanoid then
local creatorValue = character.Humanoid:FindFirstChild("creator")
if creatorValue then
local killerName = creatorValue.Value
local killer = Players:FindFirstChild(killerName)
local deathPlayer = Players:FindFirstChild(player.Name)
print("we are here")
if killer and deathPlayer then
killer.leaderstats.Time.Value += deathPlayer.leaderstats.Time.Value
deathPlayer.leaderstats.Time.Value = 0
else
warn("Killer or death player not found.")
end
else
warn("Creator value not found in Humanoid.")
end
end
end)
end)
end)
This code is supposed to work like this:
- Check when a player died
- Find out who killed who
- Give the killer the prey’s time and put the prey’s time at 0.
For some reason, I cannot get the killer’s name.
The output prints this:
we are here
Killer or death player not found.
Please help!
Thanks
-GreenTreeGamingYT