local MAX_MINION = 3 function getSpawns() local c = game.Workspace.BlueMinionSpawns:GetChildren() local spawns = {} for index, child in pairs(c) do if child.Name == "BlueMinionSpawn" then table.insert(spawns, child) end end return spawns end function pickRandomChild(tab) return tab[math.random(1, #tab)] end function spawnMinion() local blueciviliancollection = game.Lighting.Troops.Blue.BlueCivilians:GetChildren() local spawns = getSpawns() local minion = pickRandomChild(blueciviliancollection):clone() local spawn = pickRandomChild(spawns) minion.Parent = game.Workspace minion:MakeJoints() minion:MoveTo(spawn.Position) end function minionCount() local minions = {} local c = game.Workspace:GetChildren() for index, child in pairs(c) do if child.Name == "BlueCivilian" or child.Name == "BlueGirlCivilian" then table.insert(minions, child) end end return #minions end while true do if minionCount() < MAX_MINION then if math.random(1, 2) == 1 then spawnMinion() end end wait(5) end
I've been having disconnection problems ever since I've been working on my game Civilization Domination So I've been narrowing it down from the problem. I removed a couple of scripts, and tested for a hour each for each particular one. So then I found that when I removed a script that connected to multiple, it stopped disconnecting, so I narrowed it down to Troops, Spawning, or the Masterscript.
The Masterscript simply just loads buildings and messages onto the game, and I've been using the same one for quite a while.
The troops are relatively basic models that I've been working with for a good amount of time.
The spawning was a relatively new one.. I don't see anything wrong with it, but I find that if I removed it, the game would simply stop disconnecting(Though that carries back to whether the troops are the problem or not, but I've tested it with 30 troops all in the same time.)
Does anyone have any ideas?
It depends (Since I haven't played your game, I'm not really sure) if the spawning works then it could be your computer isn't fast enough, but if it doesn't work or after a while of use, then it would mean there is an error in script messing up the sever causing sever crashes. Best way to see if this is true, get several people to test and if everyone loses connection at the same time, then it is a HUGE script error. By the way I'm not good with the whole scripting part, but I've tested enough scripts to discover these kinds of problems.
It's not my internet. I forgot to state that everyone in my server experiences this