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

MouseOver > Part.Name?

How would I make it where when you put your mouse over a brick, it says it's name in a Gui?

Something like this (with localplayer allowed in a script, just an example):

if script.Parent.MouseOver then
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = script.Parent.Name
end

1 answer

A Mouse object has a property, Target which is the instance the mouse is pointing at (or nil if it is hovering on the skybox).

Mouse objects can be obtained from a Tool or HopperBin's Equipped or Selected events, respectively, or using the GetMouse method on the Local Player (must be gotten from a local script).

Once you have a Mouse I'm calling mouse, you could make your script look like this:

while true do
	-- Also could be using mouse moved instead of a loop
	wait(0.1);
	local hovering = mouse.Target;
	if hovering then
		somelabel.Text = hovering.Name;
	else
		somelabel.Text = "You are pointing at the sky.";
	end
end

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