If I were to to do this:
Player = game.Players.LocalPlayer mouse = Player:GetMouse() function DownClick() print (mouse.Target.Name) end mouse.Button1Down:connect(DownClick)
Would it print out the name of the part you clicked?
Yes, this will work.
mouse.Target
will be the part (not model) that the mouse is hovering over, or nil
if the mouse is not hovering over any part (e.g., you click in the sky).
The "or nil
" part is very important to remember. The script you have will break if you click in the sky. Always check that mouse.Target
exists:
if mouse.Target then print(mouse.Target.Name) else print("Sky!") end