Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

MouseOver > Part.Name?

Asked by 10 years ago

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

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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
Ad

Answer this question