Hey all, I'm working on a minigame script and my loop only teleports one player. I've tried many different solutions and researched many times but no luck.

I tried using the same for loop in another script and it prints out multiple players (only in a while loop). However, this one only prints out one player and not the rest.

for i, v in ipairs(game:GetService("Players"):GetChildren()) do
			print(i,v) --only prints out one player
			local name = v.Name
			local check = workspace:FindFirstChild(name) 
			if check then
				local humanoid = v.Character:FindFirstChild("Humanoid")
				if humanoid then
					v.Character:MoveTo(spawns[i].Position) --only one player teleports
					local InGame = v.InGame
					InGame.Value = true 
					TimeUntilEnd(GameTimer) 
					local points = v.leaderstats.Points
					local wins = v.leaderstats.Wins
					-- wins and losses
					if InGame.Value == true then
						print("you win")
						table.insert(winTable, name)
						points.Value = points.Value + 50
						wins.Value = wins.Value + 1
					else
						print("you lost")
					end
				end
			end
		end

5 comments

0

You tested it in studio? if so, there will be only you in studio

0

I tested it with multiple players in game, and multiple test players in studio.

0

If this code runs as soon as the server starts there will only be one player in the game as it run

0

I'll try delaying the while loop for the minigame, maybe that'll solve it. I don't know what else would cause it.

0

Figured out the issue.