local Player = game:GetService("Players").LocalPlayer;
local Mouse = Player:GetMouse();
local UIS = game:GetService("UserInputService");
local RS = game:GetService("RunService");

local Gui = Instance.new("ScreenGui", Player:WaitForChild("PlayerGui"));
local Label = Instance.new("TextLabel", Gui);
Label.Size = UDim2.new(0, 100, 0, 10);
Label.AnchorPoint = Vector2.new(0.5, 0.5);

RS:BindToRenderStep("MouseHover", Enum.RenderPriority.Camera.Value - 1, function()
	
	local mPos = UIS:GetMouseLocation();
	Label.Position = UDim2.new(0, mPos.X, 0, mPos.Y);
	
	local Target = Mouse.Target;
	
	if Target then
		if Target.Parent then
			if Target.Parent:IsA("Model") and not (Target.Parent == workspace) then
				local tPlayer = game:GetService("Players"):GetPlayerFromCharacter(Target.Parent);
				if tPlayer then
					Label.Text = tPlayer.Name;
				else
					Label.Text = "Model: " .. Target.Parent.Name;
				end;
			else
				Label.Text = "Object: " .. Target.Name;
			end;
		else
			Label.Text = "Object: " .. Target.Name;
		end;
	else
		Label.Text = "nil";
	end;
	
end);

When I hover over my player it returns nil. However if I hover over a Dummy it works fine. Can anyone help?

2 comments

0

as far as I know your mouse cant target your player to prevent stuff like guns from hitting yourself. That will be why it returns nil

0

so if i did it to another player it would show?