Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My game constantly disconnects, and I've narrowed it down to a spawning script?

Asked by
3dsonicdx 163
10 years ago
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?

0
Is it a 'You have disconnect from the game' or a crash? Bebee2 195 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago
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.
0
Why did it format like this....? CoolLightningNinja 25 — 10y
Ad
Log in to vote
0
Answered by
Kozero 120
10 years ago

Maybe your internet is the problem.How much Mbps do you run on?

Log in to vote
0
Answered by
3dsonicdx 163
10 years ago

It's not my internet. I forgot to state that everyone in my server experiences this

Answer this question