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

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

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

✓ Accepted answer

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 comment

1

Thanks, and I do have a TextLabel. :D

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