Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Table will only add one player?

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.

2 comments

0

Im not too sure, but could it possibly because its only firing once then loops? Idk. Maybe add a coroutine

0

I've tried coroutines but still only adds a single player to the table

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.