local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Move:connect(function()
if Mouse.Target and Mouse.Target == Player = then
Player.PlayerGui.ScreenGui.SpecialHoverGui.Visible = true
elseif Mouse.Target and Mouse.Target ~= Player then
Player.PlayerGui.ScreenGui.SpecialHoverGui.Text = "Player.Name.."
Player.PlayerGui.ScreenGui.SpecialHoverGui.Visible = false
end
end)
✓ ANSWER ACCEPTED
How Can I Make It When My Mouse Hovers Over A Player A Gui Comes Up With There Name?
1 answer
✓ Accepted answer
Not sure if you wanted it to display the GUI when the user hovered over their own character or not, but you had the right idea. Also, by default, Mouse.TargetFilter is set to the player's character, meaning the
target would be the object behind the character. Also, next time, please put your code into lua code tags (~~~~~~~~~~~~~~~~~)
local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.TargetFilter = nil -- Set TargetFilter to nil so it doesn't ignore the character..
Mouse.Move:connect(function()
if not Mouse.Target.Parent then return end -- checking if the target's parent is not nil
if Mouse.Target and Mouse.Target.Parent == Player.Character then
Player.PlayerGui.ScreenGui.SpecialHoverGui.Text = Player.Name
Player.PlayerGui.ScreenGui.SpecialHoverGui.Visible = true
elseif Mouse.Target and Mouse.Target.Parent ~= Player.Character then
Player.PlayerGui.ScreenGui.SpecialHoverGui.Visible = false
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
