I have a UI (yes, it’s a leaderboard) and every frame is the players username ingame but a bug came out which was that if someone joined there was a chance for their frame to be duplicated (basically 2 frames with their headshot,name,displayname on it)
Function CheckForDuplicates(player)
local elements = 0
for x, textlabel in ipairs(ElementParent:GetChildren()) do
if textlabel.Name == player.Name and elements == 0 then
elements = elements + 1 -- basically store only one element, restart the loop without removing it, remove any other element found after
else textlabel:Destroy()
end
end
end