Trouble changing the text within a text box

Hey there,

So i am currently having trouble with a script and would appreciate some assistance.

The problem is that a script is not changing the text contained within a text box and i get this output error:

attempt to index string with 'Text

The script is contained within a Local Script, the script is here:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

local template = script:WaitForChild("PlayerUsername")

local scroller = script.Parent:WaitForChild("LeaderboardScroller")

function playerUpdate()
	for i, v in pairs(scroller:GetChildren()) do
		if v:IsA("Frame") then v:Destroy() end
	end
	for i, plr in pairs(game.Players:GetPlayers()) do
		
		local templateClone = template:Clone()
		
		templateClone.Name.Text = plr.Name -- The error occurs here
		templateClone.Parent = scroller
		
		scroller.CanvasSize = UDim2.new(0,0,0, scroller.UIListLayout.AbsoluteContentSize.Y)
		
	end
end

playerUpdate()
game.Players.PlayerAdded:Connect(playerUpdate)
game.Players.PlayerRemoving:Connect(playerUpdate)

Im not too sure as to why this is happening since it has worked previously in other scripts.

Thank You! :slight_smile:

the problem is because “Name” is a property of templateClone instance which i guess it’s a frame or some other gui object and .Text isn’t a descendant/property of Name so it’s erroring because you’re trying to get a property of a property, i’d suggest changing the name of “Name” to something such as PlayerName instead.

1 Like