Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I find the player who killed another player?

For an example, If I killed ROBLOX in a game how do I make it so that when I do kill them the output says "AllianceScripter Killed ROBLOX!"?

2 answers

Let's say that you killed them with a Sword, you would use two StringValues that are inside of this Sword, and inside this Sword was a LocalScript, inside this you would insert this code:

Tool = script.Parent

PlayerNameValue = Tool.[Name Of StringValue]
PlayerNameValue.Value = game.Players.LocalPlayer.Name

OtherPlayerName = Tool.[Name Of StringValue]

Tool.Handle.Touched:connect(function(hit)
	local Humanoid = hit.Parent:FindFirstChild("Humanoid")
	if (Humanoid) then
		OtherPlayerName.Value = hit.Parent.Name
		Humanoid.Changed:connect(function()
			if Humanoid.Health == 0 then
				print(PlayerNameValue.Value.." killed "..OtherPlayerName.Value.."!")
			end
		end)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.