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

Why won't it change the text to the players name?

Why won't it change the text to the players name?

Nametag is a BillboardGui

local Nametag = game:GetService("ReplicatedStorage"):WaitForChild("Nametag")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		
		print(player.Name)
		local ClonedNametag = Nametag:Clone()
		ClonedNametag.Parent = game.Workspace:WaitForChild(player.Name).Head
		ClonedNametag.Name.Text = player.Name
	end)
end)

Error - Workspace.Scripts.NameTag:9: attempt to index field 'Name' (a string value)

1 answer

I assume you have a TextLabel named "Name" in your billboardGui, Roblox is thinking that ClonedNametag.Name.Text is referencing the Name of the BillBoardGui, and not the TextLabel, now BillBoardGui's Name doesnt have a Text property which is why you got the error

You can either rename textlabel or reference the textlabel correctly

local Nametag = game:GetService("ReplicatedStorage"):WaitForChild("Nametag")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)

        print(player.Name)
        local ClonedNametag = Nametag:Clone()
        ClonedNametag.Parent = game.Workspace:WaitForChild(player.Name).Head
        ClonedNametag["Name"].Text = player.Name
    end)
end)

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