How do I check the last player that owned the sword?

So, when the player touches the rock, they get the sword on top of their head and it shows a message to all players that they have it. But in play if the player keeps jumping on the rock it will spam the message. I want it so that it only shows the message if its a different person.

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	local last = game.Players:GetPlayerFromCharacter(hit.Parent)
	if touched == false then
		
		billboard.Adornee = player.Character.Head
		billboard.ImageLabel.Rotation = 0
		touched = true
		
		local m = Instance.new("Message")
		m.Text = player.Name.." got the Sword!"
		m.Parent = workspace
		wait(2)
		remoteEvent:FireAllClients(player.Name)
		m.Parent = game.ServerStorage
	while wait(2) do
		if player.Character.Humanoid.Health == 0 then
		billboard.ImageLabel.Rotation = 120
			billboard.Adornee = script.Parent
			wait(2)
			touched = false
		end
		end
		end
	
end)

Create a variable that is equal to none. Then, have an if statement detecting if that variable is equal to the players name, if it is, do nothing. If it isn’t, set the variable equal to the players name and do what you want the script to do.

Try replacing while wait(2) do with:

player.Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
-- Code
end)

like this ?

local last = none
if player.Name == none then
print("nothing")
else 
-- code
end

Put this in quotes as it’ll error out., also check if it’s equal to last, not none.