How to overcome this clone?

why this happened, i am really wondering whether i wrote the wrong part or what. if yes please tell me the solution :slightly_smiling_face:

Code

local main = script.Parent.MainFrame
local ListFrame = main.List_Server
local SiniFrameAll = script
local TomoblUlang  = main:WaitForChild("UlangBang")
local ServerLain = SiniFrameAll:WaitForChild("ServerFrameBang")
local ServerFrameCs = SiniFrameAll:WaitForChild("MuServer")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local RemotEv = ReplicatedStorage.FolderDataServerNya:WaitForChild("ServerData")
local TeleportServer = ReplicatedStorage.FolderDataServerNya:WaitForChild("TeleportServer")
local RemoteDataCenter = ReplicatedStorage.FolderDataServerNya:WaitForChild("DataCenterServer")

local KoneksiSer = {}
local Max_Players = Players.MaxPlayers
local Server_Daftar = {}
local Player_List = {}
local COD_D = "SERVERDUNIA"
local Teleport_Service = game:GetService("TeleportService")
local PesanBang = 5

local playerKlien = Players.LocalPlayer
local Teman_ADA = {}

local function TemanMuadaDIsini()
	Teman_ADA = {}
	local success, result = pcall(function()
		return Players:GetFriendsAsync(playerKlien.UserId)
	end)

	if success and result then
		for _, item in pairs(result:GetCurrentPage()) do
			table.insert(Teman_ADA, tonumber(item.id))
		end
	end
end

function TextB(Button, newText, revertText)
	Button.Text = newText
	task.delay(PesanBang, function()
		Button.Text = revertText
	end)
end

Players.PlayerAdded:Connect(function(player)
	table.insert(Player_List, player.UserId)
end)

Players.PlayerRemoving:Connect(function(player)
	for i, v in ipairs(Player_List) do
		if v == player.UserId then
			table.remove(Player_List, i)
			break
		end
	end
end)

local function FotoPlayer_KTP(userId, parent)
	local thumbUrl = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)

	local FotoNyaPlayer = Instance.new("ImageLabel")
	FotoNyaPlayer.Size = UDim2.new(0, 50, 0, 50)
	FotoNyaPlayer.Image = thumbUrl
	FotoNyaPlayer.BackgroundTransparency = 1
	FotoNyaPlayer.Parent = parent

	local Cuy_UICorner = Instance.new("UICorner")
	Cuy_UICorner.CornerRadius = UDim.new(1, 0)
	Cuy_UICorner.Parent = FotoNyaPlayer

	local JagaJARAK_UI = Instance.new("UIAspectRatioConstraint")
	JagaJARAK_UI.AspectRatio = 1
	JagaJARAK_UI.Parent = FotoNyaPlayer
end

local function ServerUpdate()
	
	for _, child in ipairs(ListFrame:GetChildren()) do
		if child:IsA("Frame") and (child.Name == "MuServer" or child.Name == "ServerFrameBang") then
			child:Destroy()
		end
	end

	TemanMuadaDIsini()
	
	for _, Kontek in ipairs(KoneksiSer) do
		Kontek:Disconnect()
	end
	
	KoneksiSer = {}

	local DataCS
	local success, result = pcall(function()
		return RemoteDataCenter:InvokeServer()
	end)

	if success and typeof(result) == "table" then
		DataCS = result
	else
		DataCS = {{["RegionName"] = "Getting data...", ["ServerStartTime"] = os.time()}}
	end


	do
		local ServerFrm = ServerFrameCs:Clone()
		ServerFrm.Visible = true
		ServerFrm.Parent = ListFrame
		
		
	--	ServerFrm.Region.Text = tostring(DataCS["RegionName"])
		ServerFrm.Players.Text = "Players: " .. #Players:GetPlayers() .. "/" .. tostring(Max_Players)

		local fotoFrame = ServerFrm:FindFirstChild("FrameFotoPlayer")

		if fotoFrame then
			for _, child in ipairs(fotoFrame:GetChildren()) do
				if child:IsA("ImageLabel") or child:IsA("TextLabel") then
					child:Destroy()
				end
			end

			local maxDisplay = 5
			local localPlayers = Players:GetPlayers()
			for i = 1, math.min(#localPlayers, maxDisplay) do
				FotoPlayer_KTP(localPlayers[i].UserId, fotoFrame)
			end

			if #localPlayers > maxDisplay then
				local more = Instance.new("TextLabel")
				more.Size = UDim2.new(0, 50, 0, 50)
				more.Text = "+" .. tostring(#localPlayers - maxDisplay)
				more.BackgroundTransparency = 1
				more.TextScaled = true
				more.TextColor3 = Color3.new(1, 1, 1)
				more.Parent = fotoFrame
			end
		end
	end
	
	for _, data in ipairs(Player_List) do
		local ServerFrame = ServerLain:Clone()
		ServerFrame.Visible = true
		ServerFrame.Parent = ListFrame

		--ServerFrame.Region.Text = tostring(data["RegionName"])
		ServerFrame.Players.Text = "Players: " .. #data["plrs"] .. "/" .. tostring(Max_Players)
		
		local ServerPenuhBang = #data["plrs"] >= Max_Players
		
		if ServerPenuhBang then
			ServerFrame.FotoKunci.Visible = true
			ServerFrame.JoinBtn.Text = "Server Full"
			ServerFrame.JoinBtn.UIStroke.Color = Color3.new(0.552941, 0.282353, 0.290196)
			ServerFrame.JoinBtn.BackgroundColor3 = Color3.new(0.886275, 0.396078, 0.403922)
			ServerFrame.JoinBtn.TextColor3 = Color3.new(0.439216, 0.192157, 0.196078)
			ServerFrame.JoinBtn.MouseButton1Click:Connect(function()
				ServerFrame.success:Play()
			end)
		else
			ServerFrame.FotoKunci.Visible = false
			ServerFrame.JoinBtn.UIStroke.Color = Color3.new(0.266667, 0.796078, 0.388235)
			ServerFrame.JoinBtn.Text = "Join"
			ServerFrame.JoinBtn.BackgroundColor3 = Color3.new(0.333333, 1, 0.498039)
			ServerFrame.JoinBtn.TextColor3 = Color3.new(0.109804, 0.32549, 0.160784)
		end

		local conn = ServerFrame.JoinBtn.MouseButton1Click:Connect(function()
			TeleportServer:FireServer(data["job_id"], "ToServer")
		end)
		
		table.insert(KoneksiSer, conn)

		if data["hasFriend"] then
			local friendBtn = ServerFrame.JoinTeman
			friendBtn.Visible = true
			
			friendBtn.MouseButton1Click:Connect(function()
				TeleportServer:FireServer(data["job_id"], "ToServer")
			end)
		end

		local fotoFrame = ServerFrame:FindFirstChild("FrameFotoPlayer")
		if fotoFrame then
			for _, child in ipairs(fotoFrame:GetChildren()) do
				if child:IsA("ImageLabel") or child:IsA("TextLabel") then
					child:Destroy()
				end
			end

			local playerList = typeof(data["plrs"]) == "table" and data["plrs"] or {}
			local maxDisplay = 5
			for i = 1, math.min(#playerList, maxDisplay) do
				FotoPlayer_KTP(playerList[i], fotoFrame)
			end

			if #playerList > maxDisplay then
				local more = Instance.new("TextLabel")
				more.Size = UDim2.new(0, 50, 0, 50)
				more.Text = "+" .. tostring(#playerList - maxDisplay)
				more.BackgroundTransparency = 1
				more.TextScaled = true
				more.TextColor3 = Color3.new(1, 1, 1)
				more.Parent = fotoFrame
			end
		else
			warn("FrameFotoPlayer tidak ditemukan di Sample")
		end
	end
end

RemotEv.OnClientEvent:Connect(function(serverData)
	Player_List = {}

	for job_id, t in pairs(serverData) do
		local temp = table.clone(t["data"])
		temp["plrs"] = t["plrs"]
		temp["job_id"] = job_id

		local hasFriend = false
		for _, userId in ipairs(temp["plrs"]) do
			if table.find(Teman_ADA, userId) then
				hasFriend = true
				break
			end
		end
		temp["hasFriend"] = hasFriend

		table.insert(Player_List, temp)
	end

	if COD_D == "SERVERDUNIA" then
		table.sort(Player_List, function(Value1, Value2)
			return #Value1["plrs"] < #Value2["plrs"]
		end)
	else
		table.sort(Player_List, function(Value1, Value2)
			return #Value1["plrs"] > #Value2["plrs"]
		end)
	end

	ServerUpdate()
end)


TomoblUlang.MouseButton1Click:Connect(function()
	ServerUpdate()
end)


coroutine.wrap(function()
	while task.wait(12) do
		ServerUpdate()
	end
end)()

we are not LLM bro.
Tell us the problem and where you suspect it to accour.

1 Like

When starting the game and clicking the Refresh button, I’ve already created an anti-clone.

	for _, child in ipairs(ListFrame:GetChildren()) do
		if child:IsA("Frame") and (child.Name == "MuServer" or child.Name == "ServerFrameBang") then
			child:Destroy()
		end
	end

but why is there still more than 1 Clone Server

You are cloning this for each player in the game with this code snippet from your code, where you iterate through the players:

for _, data in ipairs(Player_List) do
		local ServerFrame = ServerLain:Clone()
                -- the rest of your code
end
1 Like

Yes, this is the cause. Thank you very much. Now it’s starting to return to normal.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.