I've been searching for quite a while for an answer to this question, and I've only ever found one thing related to it anywhere on this website or on roblox devforum.
I've created a custom leaderboard UI, with two sections on it, each corresponding to a team. When there is one player in the server, it displays the player's name on the correct side of the GUI - the side corresponding to the player's team. However, if you go to 2 or more players, for some reason it duplicates and shows players on both sides, no matter what, as shown below:
This is the part of the script dedicated solely to handling the playerlist:
function fill()
wait(.5)
clear()
for _, player in pairs(game.Players:GetChildren()) do
for i,v in pairs(game.Players:GetChildren()) do
if v.Team == game.Teams["Team A Dead"] or v.Team == game.Teams["Team A"] then
print(player.Name .." is on Blue Team")
local new = template:Clone()
new.Name = player.Name
new.Username.Text = player.Name
new.Parent = plistblue
elseif v.Team == game.Teams["Team B Dead"] or v.Team == game.Teams["Team B"] then
print(player.Name .." is on Red Team")
local new2 = template:Clone()
new2.Name = player.Name
new2.Username.Text = player.Name
new2.Parent = plistred
end
end
end
end
while wait(0.5) do
fill()
end
Any sort of help would be appreciated. I feel like I've probably made a minor mistake here, however I am very very new to scripting and rely pretty heavily on seeing other people's work to understand how to make my own scripts, and this is an area where there are not a lot of available resources.
Thanks in advance.
