Today, I added an update to my game that included toggling StreamingEnabled. It’s something we have been working on for a while, and today, I bit the bullet and published the update.
However, it actually made things WORSE. An issue before StreamingEnabled was client memory usage would be high - it would be in the 3000mb range, sometimes even higher. StreamingEnabled fix that, as the client memory usage would hover in the low 2000mb range (decent for a big enough game I guess), but the ping BALLOONED. I’m talking the highest ping I’ve ever seen.
Ping would balloon like crazy, while the client memory usage would stay the same.
Players greatly complained about the lag, and rightfully so - I don’t think I’ve ever seen a 9000+ ping in my LIFE.
One of the things that I came to find out was causing the issue, was the handler for the tycoons when someone left the game.
This didn’t make any sense though, since the script is server-sided (in ServerStorage), and didn’t break before StreamingEnabled was toggled on…
--- this snippet is from Kycoon_Server
Players.PlayerRemoving:Connect(function(Player)
for _,BaseInfo in next,PlayerBases do if BaseInfo.Owner ~= Player then continue; end;
BaseInfo.Stats = nil;
BaseInfo.Owner = nil;
BaseInfo._STATS_.Value = nil;
BaseInfo._OWNER_.Value = nil;
KycoonNodes:Fire("OwnerLeft",BaseInfo,Player); --- this is line 16
end;
end);
---these snippets are from NodeX
for i,EventFunc in next,FireEvent do
local Contents = IgnoreErrors and {pcall(EventFunc,...)} or {EventFunc(...)}; if #Contents > 1 then
if IgnoreErrors and not Contents[1]then
warn(`[{EventName}-{i}]:`,select(2,unpack(Contents))); --- line 71
else
print(`[{EventName}-{i}]:`,select(IgnoreErrors and 2 or 1,unpack(Contents)));
end;
end;
table.insert(Results,Contents);
end;
---above code handles events like when someone leaves.
---the below code is gets called when the player leaves and the tycoon needs to be reset:
---the code is also in Kycoon_Server
function BaseInfo:Save(plr)
local stuffToSave = {}
for stuff,ObjectValue in next,BaseInfo.Storage_Buttons:GetChildren()do if not ObjectValue:IsA("ObjectValue")then continue; end;
local item = ObjectValue.Value; if not item or item.Parent then continue; end;
local SaveName = item:GetAttribute("SaveName"); if not SaveName then continue; end;
table.insert(stuffToSave,SaveName);
end;
local key = "base_"..plr.UserId;
local success, errormsg = pcall(function()
base_Data:UpdateAsync(key, function(prev)
print(stuffToSave,"SAVED");
return stuffToSave;
end);
end)
if success then
print(plr.Name.." base saved!");
else
warn(errormsg);
end;
end;
function BaseInfo:Reset(owner,rebirth)
if rebirth then
if BaseInfo.Rebirthing then return; end;
BaseInfo.Rebirthing = true;
end;
local base = BaseInfo.Tycoon;
local key = "base_"..owner.UserId;
local Collected = Tycoon:WaitForChild("Collected");
for Attribute in next,Collected:GetAttributes()do
Collected:SetAttribute(Attribute,nil);
end;
local Buttons = BaseInfo.Buttons;
BaseInfo.Purchased:ClearAllChildren();
task.wait();
for ButtonId,Data in next,BaseInfo.SafeCopy do
local Button = Data.Button;
Button:Clone().Parent = Buttons;
end;
if rebirth then
local success, removedValue, keyInfo = pcall(function()
base_Data:RemoveAsync(key);
end);
if success then
print(owner.Name.." has successfully rebirthed and reset their base data!");
local Leaderstats = BaseInfo.Stats;
if Leaderstats then
Leaderstats.Rebirths.Value += 1;
Leaderstats.Cash.Value = getCash.get(owner);
end;
end;
end;
BaseInfo:checkItems();
if not rebirth then return; end;
BaseInfo.Rebirthing = false;
end;
How on earth can the above code be causing this? Or could something else be causing the issue?