So… When I have alot of items in my inventory in my game (like 30-40), it drops performance SO HARD and my ping jumps to 2,000+ and the game is unplayable. Here’s a video, and a screenshot of the errors.
I already checked client, and server. Any loop I have is used on while task.wait() do or while wait() do.
Did you check how you placed your for loops and went over where all your ends belonged to? Since loading one object might cause a for loop in a for loop somehow. That’s all I can think of, because this error is new to me. I’ve never seen one like it. But why so many lines in a client script? Do you not utilize functions?
I use plenty of functions. I just use only 1 localscript. Also, all my for loops are broken when another for loop is made usually, only 2 run constantly (for GUI updating, but that was always fine)
Alright so just looked it up, and it seems you have a memory leak. Something is duplicating itself basically. I’m afraid I’m going to have to see some code.
Also, a good tip is to use multiple UIs. It looks much cleaner and doesn’t cause any performance issues or what not. Also, use more than one script! Too many "WaitForChild"s can delay a lot of vital functions like for buttons to proceed with the game.
No, just the whole spot that causes the memory leak. Just copy the UpdateCollection function and tell do the same for like 502. Line 502 might be repeating something.
function UpdateCollection(assets)
local folder = workspace.CollectionBoard;
local main = folder.main;
local board = main.Board.Board;
local list = board["List"];
table.sort(assets, function(a,b)
return a.AveragePrice > b.AveragePrice;
end)
for _,v in pairs(GetItems) do wait();
local Owned = false;
for _,item in pairs(assets) do
if v.AssetId == item.AssetId then
Owned = true;
break;
end
end
if not list:FindFirstChild(v.AssetId) then -- LINE 502
local coltemp = templates.CollectionsItem:Clone();
coltemp.Thumbnail.Image = thumbnail .. v.AssetId;
coltemp.Information.Title.Text = v.Name;
coltemp.Information.AveragePrice.Text = addtitle(v.AveragePrice);
coltemp.Information.Type.Visible = false;
coltemp.Name = v.AssetId;
if Owned then
coltemp.Information.Locled.Visible = false;
end
coltemp.Parent = list;
else
local item = list:FindFirstChild(v.AssetId);
if Owned then
item.Information.Locled.Visible = false;
else
if item then
item.Information.Locled.Visible = true;
end
end
end
list.CanvasSize = UDim2.new(0,0,0, list.UIGridLayout.AbsoluteContentSize.Y);
end
list.CanvasSize = UDim2.new(0,0,0, list.UIGridLayout.AbsoluteContentSize.Y);
end
I checked how my assets were updated, and realized I put the task.wait() BEFORE the loop instead of after. Thank you @RefusalMan for making me double check my loops hahaha