UI Textlabel is not visible

Hello,

I am trying to create a custom leaderboard but the textlabel is not visilbe (I print and it told me it’s visible but on my screen it’s not created (on client side)).

local Teams = game:GetService("Teams"):GetTeams()

local rs = game:GetService("ReplicatedStorage")
local plrs = game:GetService("Players")

local function existInArray(array, value) 
	for i,v in pairs(array) do -- v est les textLabel
		for i = 1, 30, 1 do 
			local labelName = string.sub( -- Permet de reconstituer le nom du joueur qui est dans le textlabel
				"1."..tostring(i).." "..v.Name, -- Prend le nom du textlabel
				string.find("1."..tostring(i).." "..v.Name, v.Name) -- Prend les index du nom du textlabel
			)

			if labelName == value then 
				return true 
			end
		end
	end
	return false
end

local i_police = 0

while wait(1) do 
	for _, team in pairs(Teams) do 
		if team.Name ~= "Citizen" then 
			local players = team:GetPlayers()

			if #players > 0 then 
				if not script.Parent:FindFirstChild(team.Name) then
					local title = script.Parent.FORMATTitle:Clone()
					title.Name = team.Name
					title.Text = team.Name
					title.Visible = true
					title.Parent = script.Parent
				end

				for i,v in pairs(players) do 
					if plrs:GetPlayerByUserId(plrs:GetUserIdFromNameAsync(v.Name)) then 
						local playerName = v.Name
						
						local userID = plrs:GetUserIdFromNameAsync(playerName)
						local APs = rs.Events.Modules.GetAPsUserID:InvokeServer(userID)
						local Rank = rs.Events.Modules.GetRankUserID:InvokeServer(userID)
						
						if team.Name == "Police" then
							local playerNameInTextLabel = string.sub( -- Permet de reconstituer le nom du joueur
								"1."..tostring(i_police).." "..playerName, -- Nom du label
								string.find("1."..tostring(i_police).." "..playerName, playerName) -- Prend les index du nom du joueur
							)
							
							if not existInArray(script.Parent:GetChildren(), playerNameInTextLabel) then 
								local p = script.Parent.FORMATPlayer:Clone()
								p.Name = "1."..tostring(i_police).." "..playerName
								p.Text = playerName.." | "..tostring(APs).." AP | "..tostring(Rank)
								p.Visible = true
								p.Parent = script.Parent
								
								i_police += 1
							end
						end
					end
				end
			end
		end
	end

	for i,v in ipairs(script.Parent:GetChildren()) do 
		if v:IsA("TextLabel") then
			if v.Name ~= "FORMATPlayer" and v.Name ~= "FORMATTitle" then 
				if v.Name ~= "Police" and v.Name ~= "Redacted" and v.Name ~= "Citizen" then 
					if not plrs:FindFirstChild(v.Name) then 
						v:Destroy()
					end
				end
			end
		end
	end
end

image
image
image

1 Like

If you manually add an identical textlabel in the editor does it show up? If not then the issue most likely has something to do with position or size. Have you tried selecting the textlabels in the explorer when playing? If so then do you seen an outline of the textlabel where you expect it to be?

The label does not exist in client side so I am trying to do this on server side.

Are the textlabels created on server-side?

In my new test yes, but I am getting another problem. Duplicating textlabel problem

Ok, are the textlabels created with a server script or localscript? If you’re using a server script i’d recommend using a localscript instead

The local does not work so i am testing with an event.

I’m sorry, I don’t think i’ll be able to help you with this. Good luck. I’m not a very advanced scripter.

Do not worry, I am still searching, thank you.

I hope you find a solution to your problem, good luck.

1 Like