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

How to make a players name pop up when hovered over?

Asked by
yelsew 205 Moderation Voter
8 years ago

I have tried to make a GUI that, when your mouse cursor hovers over another player, it shows their name, and when you hover off, it disappears. I've tried a couple things, but I can't seem to make it work. Here's my current code, and feel free to do whatever you need to do- even a small hint will help. :happy:

local players = game:GetService("Players")

local gui = script.Parent
local player = players.LocalPlayer
local mouse = player:GetMouse()

mouse.Move:connect(function() do

end)

1 answer

Log in to vote
1
Answered by
Lacryma 548 Moderation Voter
8 years ago

You'll need to check mouse.Target which hosts the object the mouse is pointing to. Also, I suggest you create a textlabel of some sort. However, this will put you on the right track.

Code:

local players = game:GetService("Players")

local gui = script.Parent
local player = players.LocalPlayer
local mouse = player:GetMouse()

mouse.Move:connect(function() do
    local target = mouse.Target
    if target and target.Parent:FindFirstChild("Humanoid") then
        local plr = game.Players:GetPlayerFromCharacter(target.Parent)
        if plr and plr ~= player then
            print(plr.Name)
        end
    end
end)
1
Thanks, and I do have a TextLabel. :D yelsew 205 — 8y
Ad

Answer this question