Error in pulling player.Name from a seated player

The script I constructed was meant to catch the seated players display/username and change the text on a nameplate to correspond with the seated user’s name. The script currently does nothing. There are no errors in the console.

local namegui = script.Parent.Name
local rankgui = script.Parent.Title


local Players = game:GetService("Players")

local seat = script.Parent.OfficeSeat.Value

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local humanoid = seat.Occupant

	if humanoid then
		local character = humanoid.Parent
		local player = Players:GetPlayerFromCharacter(character)

		if player then
			namegui.text = player.Name
		end
	else
		namegui.text = "Nobody"
	end
end)

image

try print(seat) to see if you get the actual seat
then print(humanoid) to see what does the Occupant returns

The dot operator accesses both children and properties. Properties take precedence over children, so accessing a child by the name “Name” via the dot operator will instead return the Instance.Name of script.Parent. You need to use Instance:FindFirstChild or change the name of the GUI to not conflict with script.Parent’s properties

ah, ‘Name’ is a property of Instance, so avoid using ‘Name’ as the name of your TextLabel
or else you have to use local namegui = script.Parent:FindFirstChild('Name') to get the label

Thank you all so much! That works now!