Currently, I am in process of remaking one of my games. I am giving it a HUGE facelift.
I use StreamingEnabled for it, since the map for it is pretty massive. I have it set to LowMemory
, with a minimum radius of 512 (the tycoons are roughly 400x400) and a target radius of 1024.
On the server, the game uses 1700-1900MB of memory, on the client, it uses around 1800-2100MB. On the higher side (especially for the client), but I’ve seen and had games with MUCH higher numbers, like this one.
An issue I’ve started running into as the game gets some players going is ping. When the server size is low, the game usually is <100 ping, which I check with the developer console.
As the game fills up, ping starts getting higher and higher, usually sitting at about 100-250. However, when a player rebirths/leaves, the ping nearly doubles, if not doubles or more:
At one point I saw ping go up to 3000-4000, I think when multiple people were leaving.
Whenever I see this, I use the ;ping command HD Admin says, and it always says I have good ping
The above issue(s) occur in servers that are barely half full - you can imagine what would happen with much fuller servers…
I had an almost identical issue like this in this game with StreamingEnabled, and it was fixed by turning off StreamingEnabled. Doing so results in the game having VERY high memory usage on the client AND server, and that generates a fair amount (but less severe) issues of its own.
I am trying to keep using StreamingEnabled with this game. The main culprit I can think of for this glitch is my tycoon system, which uses object oriented programming (OOP) via a centralized module script to handle things. I attach any connections to a janitor/maid, and clear all connections related to tycoon objects, and the tycoon object itself, when a player leaves/rebirths, and then create a new tycoon object, which I assume is the point of pressure/pain that causes this extremely high jump in ping.
Code for generating tycoons:
for number,i in pairs (game.Workspace.plots:GetChildren()) do
if not i:IsA("BasePart") then continue end
local clone = game.ServerStorage.tycoonItems.template:Clone()
clone:PivotTo(i.CFrame)
clone.Parent = workspace.tycoons
i:Destroy()
clone.PrimaryPart:Destroy()
local team = validTeams[number]
--clone.builder.values.Team.Value = team
--clone.engineer.values.Team.Value = team
task.wait()
local infoHolder = clone:FindFirstChild("infoHolder")
if infoHolder then
local billboard = infoHolder:FindFirstChildWhichIsA("BillboardGui")
if billboard then
processDefault(billboard,team)
team:GetAttributeChangedSignal("flag"):Connect(function()
if team:GetAttribute("flag") ~= nil then
processChangeFlag(billboard,team:GetAttribute("flag"))
end
end)
team:GetPropertyChangedSignal("Name"):Connect(function()
--if #team:GetPlayers() > 0 then
processChangeName(billboard,team)
--end
end)
team.PlayerRemoved:Connect(function()
if #team:GetPlayers() <= 0 then
processDefault(billboard,team)
end
end)
end
end
local newBuilder = tycoon.new(clone.builder,team)
local newEngineer = tycoon.new(clone.engineer,team)
local pointer = Instance.new("ObjectValue",team)
pointer.Name = "location"
pointer.Value = clone
clone.Name = "tycoonHolderTeam"..number
end
Code for removing and then generating a new tycoon object:
function tycoon:Reset(rebirth:boolean)
for index,value in pairs(tycoonObjects) do
if value == self then
table.remove(tycoonObjects,index)
end
end
local team = self.Team
local owner = self.owner
local clone = self.clone
local parent = self.parent
self.janny:Destroy()
clone.Parent = parent
if rebirth and owner then
local stats = owner:FindFirstChild("leaderstats")
if stats then
local rebirths:IntValue = stats:FindFirstChild("Rebirths")
local cash:IntValue = stats:FindFirstChild(cashName)
if rebirths then
cash.Value = cashGiver:Rebirthed(owner)
rebirths.Value += 1
end
end
replicatedStorage.events.client.sound:FireClient(owner,"rebirth")
data:Clear(owner,self.role)
tycoon.new(clone,team,owner)
else
tycoon.new(clone,team)
end
setmetatable(self, nil)
table.clear(self)
table.freeze(self)
end
Does anyone know how I can fix this? I can provide more code if needed…