Print name of character that damaged you

Here’s my script:

local Character = script.Parent
local lasthealth = Character.Humanoid.Health
for i,v in pairs(workspace:GetChildren()) do
	if v:FindFirstChild("HumanoidRootPart") then
		local dmghrp = v:FindFirstChild("HumanoidRootPart")
		Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
		if dmghrp then
			if (dmghrp.Position - Character:WaitForChild("HumanoidRootPart").Position).Magnitude < 1 and Character.Humanoid.Health < lasthealth then
				print(v.Name)
				end
				lasthealth = Character.Humanoid.Health
		end
	end)
end
end

But it prints space (" ") in the output. pls help

1 Like

i tried it , it print the player him self name,

try this

local Character = script.Parent
local lasthealth = Character.Humanoid.Health
for i,v in pairs(workspace:GetChildren()) do
	if v:FindFirstChild("HumanoidRootPart") then
		local dmghrp = v:FindFirstChild("HumanoidRootPart")
		Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
		if dmghrp then
			if (dmghrp.Position - Character:WaitForChild("HumanoidRootPart").Position).Magnitude < 1 and Character.Humanoid.Health < lasthealth and v ~= Character then
				print(v.Name)
				end
				lasthealth = Character.Humanoid.Health
		end
	end)
end
end