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

Table will only add one player?

Asked by
CyzDev 26
4 years ago

For some reason, the table only adds one player out of the 16 players, I'm really unsure what to do now

local playersPlaying = {}
        for i,player in pairs(game.Players:GetPlayers()) do

            local char = player.Character or player.CharacterAdded:wait()
            if char then
                local randomSpawns = map.Spawns:GetChildren()[Random.new():NextInteger(1,#map.Spawns:GetChildren())]
                if cachedSpawns[randomSpawns] then
                    repeat randomSpawns = map.Spawns:GetChildren()[Random.new():NextInteger(1,#map.Spawns:GetChildren())] wait() until not cachedSpawns[randomSpawns]
                end

                    table.insert(playersPlaying,player.UserId)

                print(playersPlaying)
                 cachedSpawns[randomSpawns] = true

                for a,b in pairs(playersPlaying) do
                     char.HumanoidRootPart.CFrame = (randomSpawns.CFrame * CFrame.new(0,2.25,0)) 
                end

                local inGame = false

                local status = Game.Stats.Status
                local gameTime = Settings.gameTimeLimit

                while wait() do
                    inGame = true
                    repeat
                     gameTime = gameTime - 1
                     status.Value = gameTime.." "..((gameTime == 1 and "Second") or "Seconds").." left."
                     wait(1)
                    until gameTime == 0  
                    break
                end
                --[[local plrs = game.Players
                local murderer = plrs:GetChildren()[math.random(1,#plrs:GetChildren())]
                print(murderer)]]--
            end
        end

Any help is appreciated.

0
Im not too sure, but could it possibly because its only firing once then loops? Idk. Maybe add a coroutine Infocus 144 — 4y
0
I've tried coroutines but still only adds a single player to the table CyzDev 26 — 4y

1 answer

Log in to vote
0
Answered by
CyzDev 26
4 years ago

I have figured it out.

0
Wrong thing -_- CyzDev 26 — 4y
Ad

Answer this question