local Mouse = game:GetService("Players").LocalPlayer:GetMouse()
local Tool = script.Parent
local Equipped
local function Equipped ()
Equipped = true
local Target = Mouse.Target
while Equipped do
if Target then
print(Target.Name)
end
Mouse.Changed:Wait()
end
end
local function Unequipped ()
Equipped = false
end
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)
This will print the name of the mouse.target if mouse.target is not nil and then will wait until the mouse moved. but even if the mouse moved it still doesn't work. It will only work once and again after re-equipping.

3 comments
I think you can remove the code on line 12 and write this instead; "repeat wait() until Mouse.Changed()"
no, i have to repeat it everytime it changes.
and while equipped is set to true