Attempt to compare number and table

  1. What do you want to achieve?
    To TP all the players ingame

  2. What is the issue?

  07:28:37.915  ServerScriptService.gameScript:67: attempt to compare number and table  -  Server - gameScript:67
  07:28:37.915  Stack Begin  -  Studio
  07:28:37.915  Script 'ServerScriptService.gameScript', Line 67  -  Studio - gameScript:67
  07:28:37.915  Stack End  -  Studio
  1. What solutions have you tried so far?
    I tried other scripts and searching for solutions in the devforum
for i = 1, #players do
	local ingameplayers = workspace.Ingame:GetChildren()
	local players = game.Players:GetChildren()

	repeat 
		players[i].Character.HumanoidRootPart.Position = map.TP.Position
		players[i].Character.Parent = workspace.Ingame
		wait()
	until ingameplayers > 1
end

Should be

until #ingameplayers > 1

Also you have other problems with the code, as it’ll only get the children once to compare, also why are you getting the Players again if you already have a varaible for that set up? You don’t need that. You don’t even the loop either, you just need to tp the character if it exists

for i = 1, #players do
	local char = players[i].Character
	if not char then continue end
	char.HumanoidRootPart.Position = map.TP.Position
	char.Parent = workspace.Ingame
	wait()
end
1 Like