Help RedM Zombies


what could be the cause of this.

           repeat
			Wait(1)

			posX = x + math.random(-Config.MaxSpawnDistance, Config.MaxSpawnDistance)
			posY = y + math.random(-Config.MaxSpawnDistance, Config.MaxSpawnDistance)

			_,posZ = GetGroundZFor_3dCoord(posX+.0,posY+.0,z,1)

			for _, player in pairs(players) do
				Wait(1)
				playerX, playerY = table.unpack(GetEntityCoords(GetPlayerPed(player), true))
				if posX > playerX - Config.MinSpawnDistance and posX < playerX + Config.MinSpawnDistance or posY > playerY - Config.MinSpawnDistance and posY < playerY + Config.MinSpawnDistance then
					canSpawn = false
					break
				else
					canSpawn = true
				end
			end
		until canSpawn

this is where im using it