Script can't set the content of a TextLabel

This leaderboard script isn’t working. It uses datastores.

local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
local Leaderboard = DataStoreService:GetOrderedDataStore("Leaderboard")

local function updateLB()
	local success, errorMessage = pcall(function()
		local Data = Leaderboard:GetSortedAsync(false, 5)
		local KillsPage = Data:GetCurrentPage()
		for Rank, Data in ipairs(KillsPage) do
			local userName = game.Players:GetNameFromUserIdAsync(tonumber(Data.key))
			print(userName)
			local Name = userName
			local Kills = Data.Value
			print(Kills)
			local isOnLeaderboard = false
			for i, v in pairs(game.Workspace.Leaderboard.SurfaceGui.Background:GetChildren()) do
				if v.Player.Text == Name then
					isOnLeaderboard = true
					break
				end
			end
			if isOnLeaderboard == false then
				local newLbFrame = game.ReplicatedStorage.LeaderboardFrame:Clone()
				newLbFrame.Parent = game.Workspace.Leaderboard.SurfaceGui.Background
				-- it just stops here for some reason
				newLbFrame.Name.Text = Name
				newLbFrame.Kills.Text = Kills
				newLbFrame.Rank.Text = "#"..Rank
				newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.Leaderboard.SurfaceGui.Background:GetChildren()), 0)
			end
		end
	end)
end

while true do
	for _, Player in pairs(game.Players:GetPlayers()) do
		Leaderboard:SetAsync(Player.UserId, Player.leaderstats.Kills.Value)
	end
	
	for _, frame in pairs(game.Workspace.Leaderboard.SurfaceGui.Background:GetChildren()) do
		frame:Destroy()
	end
	
	updateLB()
	print("update")
	
	wait(10)
end

It’s only getting to newLbFrame.Name.Text = Name for some reason.

Any help appreciated!

Simple solution

I’m guessing “Name” is a child of the frame.

You cannot have the child named “Name” because Name is also a property of Frames.
(Frame.Name = “you get the point”)
Change the name of the child “Name” to something like “PlayerName”

Thanks :slight_smile: I’m actually cringing i didn’t think of that