How to get players killer?

Hello everyone, I am trying a UI show up when a player kills someone and I try this but it doesn’t work. I have tried this to the player and it works but when I put it so it will find the player killer, it doesn’t work at all.

Script (not local)

local kill =game:GetService("ReplicatedStorage").Kill
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
	local humanoid = character.Humanoid
	humanoid.Died:Connect(function()
		local tag = humanoid:findFirstChild("creator").Value
			if tag ~= nil then
				if tag.Value ~= nil then
					wait(0.1)
					script:remove()
					kill:FireClient(tag)
				end
			end
		end)
	end)
end)

It doesn’t work out like that. You need to set the creator tag when someone hit the player with a sword/gun.

1 Like

sorry for the long wait, i wasnt focused on this part but got today so here is the code!

code:

local kill =game:GetService("ReplicatedStorage").Kill
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:connect(function(character)
		local hum = character.Humanoid
		local texttt = player.Name
	        hum.Died:Connect(function()
	           local tag = hum:FindFirstChild("creator")
                    if tag ~= nil then
	         	if tag.Value ~= nil then
				wait(0.1)
				kill:FireClient(tag.Value, texttt)	---the texttt is part of the remote event which changes the gui textlabel's text to the killed player's name	
			end
		end
	end)
end)
end)
2 Likes