Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get a Part on MouseClick?

When the mouse is clicking on a Part, how to see on wich Part he's clicking I want to know like:

print(Mouse.???.Name)

1 comment

1

Target

1 answer

✓ Accepted answer

This is a localscript in the StarterPlayerScripts and is an example only.

local mouse = game.Players.LocalPlayer:GetMouse() -- get the players mouse

local part = nil -- this will store our part when clicked

mouse.Button1Up:connect(function()
	part = mouse.Target -- this is so the value will not change as its not given to us in the event
	if part then -- nil check
		print(part) -- could also include name
	end
end)

Hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.