Need help with hovering textlabel on player bug

I have a bug in my script where if you hover over a morph part, or a hat/accessory the TextLabel’s Text displays the morph part or hat/accessory. I require for it to only display the player’s username. What change must I make to my script?

Bug: https://gyazo.com/2f6ad512450a9b70e3c9540d511f1225

Script:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local TextLabel = script.Parent

game:GetService('RunService').RenderStepped:Connect(function()
	local X = Mouse.X
	local Y = Mouse.Y

	if Mouse.Target then 
		local player = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent) or game.Players:GetPlayerFromCharacter(Mouse.Target.Parent.Parent) or game.Players:GetPlayerFromCharacter(Mouse.Target.Parent.Parent.Parent)
		if player and player ~= game.Players.LocalPlayer then
			TextLabel.Visible = true
			TextLabel.Text = Mouse.Target.Parent.Name 
			TextLabel.Position = UDim2.new(0,X,0,Y)
		else 
			TextLabel.Visible = false
		end
	end
end)

you are setting the TextLabel text to Mouse.Target.Parent although the player can also be equal to Mouse.Target.Parent.Parent and goes on i suggest replacing

TextLabel.Text = Mouse.Target.Parent.Name

to

TextLabel.Text = player.Name
1 Like