Help getting the player's mouse & checking if a player

I want the attached script (which is inside a tool (see attached explorer image)) to check when a player clicks (with the tool equipped) then check if where they click is another player.

Code:

script.Parent.Equipped:Connect(function()
	local mouse = game.Players.LocalPlayer:GetMouse()
	
	mouse.Button1Down:Connect(function()
		if mouse.Target then
			if mouse.Target.Parent:FindFirstChild("Humanoid") then
				if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then
					local e = script.Parent.Punishment:Clone()
					e.TargetPlayer.Value = mouse.Target.Parent.Name
					e.Parent = game.Players.LocalPlayer.PlayerGui
				end
			end
		end
	end)
end)

Explorer:
image

local players = game:GetService"Players"
local player = players.LocalPlayer
local mouse = player:GetMouse()

local tool = script.Parent

tool.Activated:Connect(function()
	local hitPart = mouse.Target
	if not hitPart then return end
	local hitModel = hitPart:FindFirstAncestorOfClass"Model"
	if not hitModel then return end
	local hitPlayer = players:GetPlayerFromCharacter(hitModel)
	if not hitPlayer then return end
	print(hitPlayer.Name)
end)

image

image

Bare in mind the legacy mouse object blacklists its client’s characters from its Target property.

Ok. So what does this script do?